owilsky Posted October 18, 2006 Posted October 18, 2006 Hi, is it possible to get the dot operator to match a line break? Normally . means [^\n] What I need: Get all text from first line break until two line breaks, that means get all lines beginning from the second line until there is an empty line. Something like this: \r\n(.+?)\r\n *\r\n Unfortunately I only get the first line because (.+?) only goes to the first line break. I know that this is perl compatible, but most regex engines have some kind of switches. Are there any? I use the latest beta (3.2.1.10) Thanks, Oliver
Rad Posted October 18, 2006 Posted October 18, 2006 My mind is pretty simple when it comes to programming and usually I cant grasp the point very quickly, but this is just confusing to no end Get all text from first line break until two line breaks, that means get all lines beginning from the second line until there is an empty line.i can barely read this The line break in autoit is @CRLFexample: msgbox(0,"","Line" & @CRLF & "Break")
The Kandie Man Posted October 18, 2006 Posted October 18, 2006 (edited) My mind is pretty simple when it comes to programming and usually I cant grasp the point very quickly, but this is just confusing to no end i can barely read this The line break in autoit is @CRLFexample: msgbox(0,"","Line" & @CRLF & "Break")@CRLF is a combined Carriage return (Chr(13)) and a Line feed, (Chr(10)). Keep in mind based upon what you are using that you can use either of them separately. The most common one for linebreaks is @LF. You can also use @CR. Edited October 18, 2006 by The Kandie Man "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire
Rad Posted October 18, 2006 Posted October 18, 2006 Whats the difference anyway? my friend used to complain about me using @CRLF instead of @CR and @LF but he never explained itThe descriptions are terrible in the helpfile@CR Carriage return, Chr(13); sometimes used for line breaks. @CRLF = @CR & @LF ;occasionally used for line breaks. @LF Line feed, Chr(10); typically used for line breaks. It cracks me up at how simple they are too...
The Kandie Man Posted October 18, 2006 Posted October 18, 2006 Whats the difference anyway? my friend used to complain about me using @CRLF instead of @CR and @LF but he never explained itThe descriptions are terrible in the helpfile@CR Carriage return, Chr(13); sometimes used for line breaks. @CRLF = @CR & @LF ;occasionally used for line breaks. @LF Line feed, Chr(10); typically used for line breaks. It cracks me up at how simple they are too... @CRLF is two bytes in length. @LF is one byte in length and @CR is also one byte in length. @LF is more commonly used and therefore is the best choice because it is both small in size and commonly used. "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire
Rad Posted October 18, 2006 Posted October 18, 2006 oh ok but my harddrive has 73863176192 bytes so really it doesntmake a difference but oh well ill start using lf from now on!
MHz Posted October 18, 2006 Posted October 18, 2006 is it possible to get the dot operator to match a line break? Normally . means [^\n]\r\n is windows standard so unsure where you get only \n from? If you want your pattern to match multiline as one, then start the pattern with this group "(?s)". That will make the dot token match the remainder of the regex pattern including newlines. @CRLF is two bytes in length. @LF is one byte in length and @CR is also one byte in length. @LF is more commonly used and therefore is the best choice because it is both small in size and commonly used. EOL Standards @CRLF used by Windows. @LF used by Linux\Unix. @CR used by Macintosh.
owilsky Posted October 18, 2006 Author Posted October 18, 2006 If you want your pattern to match multiline as one, then start the pattern with this group "(?s)". That will make the dot token match the remainder of the regex pattern including newlines.This was the info I needed. Thanks a lot! I know that there is @CRLF etc, but that does not help me with regex.I also know that on windows I have to use \r\n instead of only \n. That was only an example.The informataion I was looking for was the "(?s)".Thanks again!Oliver
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now