Hello group! I've been trying to replace a string with StringReplacer, if the text line contains certain text. So basically it's a classic ifthen conditional in regex, though I'm new to conditional tests in regex.
My text string is:
#1=IFCCARTESIANPOINT((1,1));
If the text string contains IFCCARTESIANPOINT then search for ));.
I tried syntax (?(A)X), If A then X, thus my regex:
(?(IFCCARTESIANPOINT)[)][)];) but it doesn't work at all.
I'd very much appreciate help :)
Best answer by ebygomm
The syntax you are using tests for if something is preceded by, not if the line in general contains the text. There are some additional characters before your text string which you need to handle. If you don't know what they are something like this would work in a string replacer. The .* matches but doesn't return everything between IFCCARTESIANPOINT and the ));
(?<=IFCCARTESIANPOINT).*(\)\);)
Edit: the above doesn't appear to work in FME. You can capture the extra characters separately then reinsert however
(?<=IFCCARTESIANPOINT)(.*)(\)\);)
Replacement text needs to be \1 followed by whatever you want to replace the )); with
The syntax you are using tests for if something is preceded by, not if the line in general contains the text. There are some additional characters before your text string which you need to handle. If you don't know what they are something like this would work in a string replacer. The .* matches but doesn't return everything between IFCCARTESIANPOINT and the ));
(?<=IFCCARTESIANPOINT).*(\)\);)
Edit: the above doesn't appear to work in FME. You can capture the extra characters separately then reinsert however
(?<=IFCCARTESIANPOINT)(.*)(\)\);)
Replacement text needs to be \1 followed by whatever you want to replace the )); with
The syntax you are using tests for if something is preceded by, not if the line in general contains the text. There are some additional characters before your text string which you need to handle. If you don't know what they are something like this would work in a string replacer. The .* matches but doesn't return everything between IFCCARTESIANPOINT and the ));
(?<=IFCCARTESIANPOINT).*(\)\);)
Edit: the above doesn't appear to work in FME. You can capture the extra characters separately then reinsert however
(?<=IFCCARTESIANPOINT)(.*)(\)\);)
Replacement text needs to be \1 followed by whatever you want to replace the )); with
Thank you very much @egomm! It would've taken so much time to figure that out. It works perfectly.
We use 3 different kinds of cookies. You can choose which cookies you want to accept. We need basic cookies to make this site work, therefore these are the minimum you can select. Learn more about our cookies.