Remove anything before certain combination
I want to leave the last part like "word+000" combination, remove anything before:
Like:
“34_ert345wers000” would become "wers000"
"fdsf_grge000" would become "grge000"
"#^%^$%jnrjr000" would become "jnrjr000"
I tried replace method,
Text to be replaced: (.+)(\w*000)
Replace with: $2
But it didn't work properly, the regular expressions will always search from left to right, so it cannot decide (\w*000) first and then decide the left.
Like:
“34_ert345wers000” would become "wers000"
"fdsf_grge000" would become "grge000"
"#^%^$%jnrjr000" would become "jnrjr000"
I tried replace method,
Text to be replaced: (.+)(\w*000)
Replace with: $2
But it didn't work properly, the regular expressions will always search from left to right, so it cannot decide (\w*000) first and then decide the left.
You have two problems...
1) The metacharacter \w will match numerical digits and underscore as well as letters
ie \w = [a-zA-Z0-9_]
so you need to explicitly define the characters you wish to match as [a-z]
(or [a-zA-Z] if your regex is case-sensitive).
2) The "+" & "*" modifiers are "greedy" by default so ".+" will match everything - including word characters - up to "000" in your regex. The solution is to append "?" to the modifier, which is an instruction for the modifier to be "lazy".
So...
Replace: .*?([a-z]*000$)
With: \1
1) The metacharacter \w will match numerical digits and underscore as well as letters
ie \w = [a-zA-Z0-9_]
so you need to explicitly define the characters you wish to match as [a-z]
(or [a-zA-Z] if your regex is case-sensitive).
2) The "+" & "*" modifiers are "greedy" by default so ".+" will match everything - including word characters - up to "000" in your regex. The solution is to append "?" to the modifier, which is an instruction for the modifier to be "lazy".
So...
Replace: .*?([a-z]*000$)
With: \1
Reply to #2:
That's worked out so well, Thank you very much!
Meanwhile I learnt a lot, thank you!
That's worked out so well, Thank you very much!
Meanwhile I learnt a lot, thank you!