Reputation: 25
I'm attempting to extract a series of data values from a text file.
The values are in the format: <MODIFIER NAME1 VALUE; MODIFIER NAME2 VALUE;>
For the purposes of the current task that I have, I only care about extracting the VALUE that is situated next to each semicolon. What would the REGEX command look like that would isolate each of these VALUES (preferably so that I backreference all values in the replacement part of my processing.) I believe that ^(.*?); is somehow used, but I'm not seeing how to isolate only the word that is attached to the semicolon in a group for backreference use.
Upvotes: 0
Views: 447
Reputation: 31196
The exact syntax depends on the language, but the following regex should do it
"(\w+);"
I used the c# syntax. In other languages, the syntax might change a bit, but the actual regex remains the same.
where \w
means any letter(it also includes 0-9 and '_), and the parenthesis signify that you capture the group inside.
if you want only letters, you can change the \w
to [a-zA-Z]
(again, different languages may or may not have different syntax for this)
I use This reference to reference my c# regex syntax. If you're using another language, that will also have something similar somewhere.
Upvotes: 1