7
Good morning to all,
I would like to run a string search for some specific strings, but in the project we are working on we have no access to any function find
or similar, only to a regular expression-based substitution function (something like replace(string, regex, replacement)
).
The idea then would be to select all the characters EXCEPT the sequences I want to find. Thus, I would remove these unwanted characters and compare with what I want to find.
Example (not a specific language):
string expReg = ??????;
string texto = "xxxxxxxxboloxxxxxxxfarinhaxxxxxxacucarxxxx";
string busca = replace(texto, expReg, "");
if(busca == "bolofarinhaacucar"){
return("Sucesso");
}
Luckily the words we need to find need to be in the defined order, so it would not be necessary to include all permutations.
We try to find some solution using regular expressions, but we always bump into the problem that the positive lookbehind (?<=ABC)
not supported in Javascript.
Any idea?
which language? Javascript?
– gmsantos
Just out of curiosity: what is this language that does not have a find but has replace?
– André Ribeiro
It’s actually a script used by a system in the company where I work. We also find it strange that he does not support find, but supports replace (even with regular expressions!), but does what, right...
– diogoan