Saving substrings using Regular Expressions
Posted
by user362971
on Stack Overflow
See other posts from Stack Overflow
or by user362971
Published on 2010-06-09T23:22:58Z
Indexed on
2010/06/09
23:32 UTC
Read the original article
Hit count: 166
I'm new to regular expressions in Java (or any language, for that matter) and I'm wanting to do a find using them. The tricky part that I don't understand how to do is replace something inside the string that matches.
For example, if the line I'm looking for is
Person item6 [can {item thing [wrap]}]
I'm able to write a regex that finds that line, but finding what the word "thing" is (as it may differ among different lines) is my problem. I may want to either replace that word with something else or save it in a variable for later. Is there any easy way to do this using Java's regex engine?
© Stack Overflow or respective owner