Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 16 to 17 of 17
Thread: Regex help
07-28-2013, 01:03 PM #16
- Join Date
- Mar 2006
- Splendora, Texas, United States of America
- Thanked 271 Times in 265 Posts
The delimiters are "Incident Title: " and a new line character sequence. That sequence of characters is carriage return and line feed (CRLF) in Windows and line feed (LF) in Linux and OS X. The new line sequence used depends on the operating system being used to write the code.
[^\r\n]+matches one or more characters that are not CR or LF characters. If a carriage return (
\r) is encountered, the regular expression engine stops. Ditto for a line feed (new line or
Parentheses are used to create backreferences. In this case, they tell the engine to save all of those characters matched by
matchmethod, which returns an array of results. The first item in the array (
) is the full match (including "Incident Title: "; this result isn't needed), and other items are added for each backreference. There's only one backreference, so the second item in the array (
) is the information you need.For every complex problem, there is an answer that is clear, simple, and wrong.
Users who have thanked Arbitrator for this post:
07-28-2013, 11:54 PM #17
- Join Date
- May 2013
- Thanked 0 Times in 0 Posts
Aha, my googling had help me come up with a little explanation, but I got stuck with the back referencing and wondering what the difference between \r and \n was.
Thanks so much!