I'm trying to make this description generator, and I can't seem to make the first part work for one of the IF arguments as it does with the rest. It only checks the logical expression but doesn't bring the rest of the text body in the cell joined with & as it does in the case of the other IF arguments I have there linked one after the other. This example should make more sense.
try:
=INDEX(REGEXREPLACE(SUBSTITUTE(SUBSTITUTE(TRIM(FLATTEN(QUERY(TRANSPOSE(IF(IFERROR(
SPLIT(B1:B, CHAR(10)))="",,REGEXREPLACE({"", SEQUENCE(1, 100)}&". "&IFNA(VLOOKUP(
TRIM(SPLIT(B1:B, CHAR(10))),
{"ck", "click >";
"box", "select box";
"scd", "scroll down >"}, 2, 0),
SPLIT(B1:B, CHAR(10))), " ", CHAR(13)))),,9^9))),
" ", CHAR(10)), CHAR(13), " "), "^\. !?", ))
demo sheet
The first If statement encloses all the rest of the formula so if the regex matches "ck" the condition is satisfied, you get "click >" but nothing else happens. I think you can just move the final bracket so it is just after "select " like this:
=IF(REGEXMATCH(B4, "ck"),"click >",IF(REGEXMATCH(B4, "scd"),"scroll down > ",IF(REGEXMATCH(B4, "!"),"","select "))) & ARRAYFORMULA(REGEXREPLACE(REGEXREPLACE(REGEXREPLACE(REGEXREPLACE(TEXTJOIN(CHAR(10), 1, IF(REGEXMATCH(""&
SPLIT(B4, CHAR(10)), "^>.*"),
SPLIT(B4, CHAR(10)), TRANSPOSE(MMULT(TRANSPOSE(TRANSPOSE((SEQUENCE(1, COLUMNS(
SPLIT(B4, CHAR(10))))<=SEQUENCE(COLUMNS(
SPLIT(B4, CHAR(10))), 1, 0))*NOT(REGEXMATCH(
SPLIT(B4, CHAR(10)), "^>.+")))), TRANSPOSE(SIGN(NOT(REGEXMATCH(
SPLIT(B4, CHAR(10)), "^>.+"))))))&". "&
SPLIT(B4, CHAR(10)))), "^0. ", ),"scd",""),"ck",""),"!",""))
I have a string vector that looks like:
> string_vec
[1] "XXX" "Snakes On A Plane" "Mask of the Ninja" "Ruslan"
[5] "Kill Switch" "Buddy Holly Story, The" "Believers, The" "Closet, The"
[9] "Eyes of Tammy Faye, The" "Gymnast, The" "Hunger, The"
There are some names which contain ", The" in the end. I want to delete the comma and the space and move the "The" before all other text.
For e.g.: "Buddy Holly Story, The" becomes "The Buddy Holly Story".
Isolating the records with the pattern was easy :
string_vec[grepl("[Aa-zZ]+, The", string_vec) == TRUE]
How can I adjust the position now?
data
string_vec <- c("XXX", "Snakes On A Plane", "Mask of the Ninja",
"Ruslan",
"Kill Switch", "Buddy Holly Story, The", "Believers, The",
"Closet, The",
"Eyes of Tammy Faye, The", "Gymnast, The", "Hunger, The")
You may try
sub('^(.*), The', 'The \\1', string_vec)
#[1] "XXX" "Snakes On A Plane" "Mask of the Ninja"
#[4] "Ruslan" "Kill Switch" "The Buddy Holly Story"
#[7] "The Believers" "The Closet" "The Eyes of Tammy Faye"
#[10] "The Gymnast" "The Hunger"
I have this string:
c <- "thethirsty thirsty itthirsty (thirsty) is"
I want the output to be as
"thethirsty thirsty itthirsty no is"
This is what I am trying.
gsub(" (thirsty) ", " no ", c)
This is what I am getting. Why does not it work? And suggest an alternative to do this.
"thethirsty no itthirsty (thirsty) is"
By default gsub interprets the first parameter as a regular expression. You don't want that and should set fixed=TRUE:
gsub(" (thirsty) ", " no ", c, fixed=TRUE)
#[1] "thethirsty thirsty itthirsty no is"
I'm trying to remove comments in C++ with flex.
This is my example code:
cout << "Pulapka \" \
// ma \
/* ma */ \
" << endl;
cout << /*Proba*/"Zabawa \" // ala i kot " << endl;
I want match everything between " ".
My regural expression:
(\"[^[]*]*")
I want to stop my matching after second quotation marks. That's mean I need only this fragment:
"Pulapka \" \
// ma \
/* ma */ \
"
The following regex works for me:
(\".*?(?<!\\)("))
You can then extract the first group which is exactly what you want.
Note: I don't know how it works for C++ but I had to use the s flag
Demo: http://regex101.com/r/xL4kU8
I have built this SPARQL Query:
String query_splInfo =
"PREFIX foaf: <http://xmlns.com/foaf/0.1/>"+"\n"+
"SELECT ?name"+"\n"+
"WHERE {?x foaf:name ?name . " +
"FILTER regex(?name, \"Studienprogrammleitung Informatik\")}";
Jena returns an error message:
Failed: com.hp.hpl.jena.query.QueryParseException: Encountered " "regex" "regex "" at line 4, column 73.
Was expecting one of:
"graph" ...
"optional" ...
"filter" ...
"{" ...
"}" ...
";" ...
"," ...
"." ...
Please help me.
"PREFIX foaf: <http://xmlns.com/foaf/0.1/>"+"\n"+
"SELECT ?name"+"\n"+
"WHERE {?x foaf:name ?name . "+"\n"+
"FILTER regex(?name, \"Studienprogrammleitung Informatik\")}";