Hi, I need a bit help with RegEx: I want it to match specific string (let's say: ABC), but only if it is at the end of the word. According to the syntax, I should use "\>" to mark end of the word so the whole string will be ABC\>
And basically it works, but only if the text I am looking for doesn't contain special characters, like dot or parenthesis. If the string is ABC. or ABC) , writing ABC.\> or ABC)\> won't match the looked string.
As I understood, for special characters I should use "escape mark" (\), but writing ABC\.\> or ABC\)\> doesn't work either.
Solved! Go to Solution.
@kwieto
Only adding ABC\.\> or ABC\)\> means you MUST have the dot or parenthesis.
Maybe we can try something like this.
and we dont really need the \> to indicate it is end of word.
Sure. Let's consider three cases:
1 | this is sample string with strings |
2 | this is sample string. With strings |
3 | (this is sample string) with strings |
I want to capture text "string." in the second row without matching "string" and "string)" from row 1 and 2, or be able to capture text "string)" from row 3 without matching "string" or "string." from row 1 or 2. And of course without word "strings" in each case.
For this example let's say I want to replace this string with the word "ABC".
So for the looked value "string." I should receive this output:
1 | this is sample string with strings |
2 | this is sample ABC With strings |
3 | (this is sample string) with strings |
and for the looked value of "string)" I should have that output:
1 | this is sample string with strings |
2 | this is sample string. With strings |
3 | (this is sample ABC with strings |
Both cases are separate, so there will be one formula for each case separately.
@flying008 - with your formula it won't match the looked string if it is in the middle of the longer string (i.e. fdsdfgdABC 4679fsdfs), as the dollar sign means end of the line. Or am I wrong?
@Qiu - I see I was not precise 😥
I don't want to capture all three cases, but only one of them. So if I look for ABC. , the formula should not match ABC or ABC) . And if I look for ABC) , then ABC and ABC. should be skipped
So this:
Only adding ABC\.\> or ABC\)\> means you MUST have the dot or parenthesis.
is correct.
@kwieto
Thank you for the feedback. Then I guess it makes thinks easier?
Thanks, this works!
I still wonder why the syntax ABC\> works, but ABC\.\> doesn't.
By the way, do you have idea how to put output text in quotes, maybe?
For example, if I want to put the whole output from your formula ( '$1ABC$2' ) in quotes, writing: '\"$1ABC$2\"' won't work :(