Sign in to follow this  
Followers 0
owilsky

RegEx: dot operator to match line break?

8 posts in this topic

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

Share this post


Link to post
Share on other sites



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 :lmao:

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 :ph34r:

The line break in autoit is @CRLF

example: msgbox(0,"","Line" & @CRLF & "Break")

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 :lmao:

i can barely read this :ph34r:

The line break in autoit is @CRLF

example: 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 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

Share this post


Link to post
Share on other sites

Whats the difference anyway? my friend used to complain about me using @CRLF instead of @CR and @LF but he never explained it

The 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... :lmao:

Share this post


Link to post
Share on other sites

Whats the difference anyway? my friend used to complain about me using @CRLF instead of @CR and @LF but he never explained it

The 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... :lmao:

@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

Share this post


Link to post
Share on other sites

oh ok but my harddrive has 73863176192 bytes so really it doesntmake a difference :lmao:

but oh well ill start using lf from now on!

Share this post


Link to post
Share on other sites

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.

:lmao:

EOL Standards

@CRLF used by Windows.

@LF used by Linux\Unix.

@CR used by Macintosh.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0