Answer the question
In order to leave comments, you need to log in
How to make a regular expression to remove text between certain occurrences in each line?
Please help me create a regular expression that will delete the text in each line between the penultimate quote and any of the LAST characters "o", "e" or "a" found. Those. in other words, I need to process the values in the last column of the table ONLY, removing the text in that column up to the letters above.
We have:
"1";"First line";"000";"emar"
"2";"Second line";"010";"eig"
"3";"Third line";"010";"end5er"
"4";"Fourth line";"010";"orn"
"5";"Fifth line";"100";"em"
Should be:
"1";"First line";
In the first line, between the last quotes, there are both "e" and "a" - it is the last character that interests us, i.e. "a" - so only "ar" should remain
Answer the question
In order to leave comments, you need to log in
(;")([^"]*)([oea])([^oea;"]*")$
The first group is a semicolon and a quote.
The second group is any (even zero) number of characters, except for the quote itself. Obviously, there may or may not be "o", "e" or "a" in this group, but they will not be the last ones. If the last "o", "e" or "a" is included in this group, then the next group will not be formed, so the regular season will not do this.
The third group of characters is clear - this is one character: "o", "e" or "a".
The fourth group of characters - any (even zero) number of characters, except for "o", "e", "a", ";" and the quotation mark itself, followed by the quotation mark. With this group we denote that the previous "o", "e" or "a"
$
at the end means the end of the line. That is, all found groups must go in that order and fit close to the end of the line. In all groups except the first, the quote is omitted, which makes it impossible to capture other segments of the string.
Obviously, you need to replace it with a combination of the found groups. Namely, the second group is redundant. I don't know exactly how it will be in Sublime. One of these should work:
$1$3$4
\1\3\4
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question