RegEx find new line

How do I create a search pattern that simply finds a new line. That’s all I want it to do? Sorry, I am very new to it.

Thanks


(new line)

\s (space)

I’m a bit unclear. Remember, RegEx is for matching, not finding, although you could certainly use it that way if you want to go through the trouble.

The pattern \\R will match any EOL character(s). The pattern code^.*$[/code] will match a single line.

Thanks people.

[quote=89543:@Kem Tekinay]I’m a bit unclear. Remember, RegEx is for matching, not finding, although you could certainly use it that way if you want to go through the trouble.

The pattern \\R will match any EOL character(s). The pattern code^.*$[/code] will match a single line.[/quote]
You are the RegEx Whisperer Kem! :slight_smile: :)Awesome!

And the People thank you :slight_smile:

What is an EOL character? Very new to regex.

Mike,
will match linefeed only, \r a carriage return. \R is a macro that will match either, or the Windows standard of \r
. The equivalent would be code[/code].

\s will match any whitespace, including spaces, EOL characters, tabs, etc.

EOL = end of line. Can be either CR-LF (Windows), LF (UNIX), or CR (Mac traditional).

End of Line character. Not all platforms have the same End Of Line (return) character.

You should buy RegExRx… It gives you those options visually that you can test on the fly.

https://itunes.apple.com/us/app/regexrx/id498370702?mt=12

[quote=89551:@Kem Tekinay]Mike,
will match linefeed only, \r a carriage return. \R is a macro that will match either, or the Windows standard of \r
. The equivalent would be code[/code].

\s will match any whitespace, including spaces, EOL characters, tabs, etc.[/quote]

I always get those confused Chr(13) / Chr(10) :slight_smile: Thanks again Kem!

Cannot afford. Should I manually consider this depending on the platform?

Oliver, its the best 5 Dollars you will ever spend (And that is USD so its probably cheaper for you with exchange rate).

It basically makes it so much more do’able having RegExRx man… Just sayin since I use it ALL of the time.

If you have read the text into a variable, use ReplaceLineEndings to replace it with whichever character you’d like:

myText = ReplaceLineEndings( myText, EndOfLine.UNIX )

If you’re trying to get each line after that, forget the regular expression and just use Split:

dim lines() as string = myText.Split( EndOfLine.UNIX )

No purchase necessary, use: http://regexpal.com

Thats a nice free RegEx “parser”, but far from a “RegEx expression building tool”. However if that is all is needed then perfect! :slight_smile:

@Oliver Scott-Brown - one additional option is to force a known end of line character into your strings using the string method “ReplaceLineEndings”. Then, you have a consistent EOL character for your strings and you don’t need to worry about the platform specifics.

For example:

// Assuming that you have a textinputstring open on a file named "theInput" theString = ReplaceLineEndings(theInput.ReadAll, EndOfLine)

Now, you simply refer to the EOL character as “EndOfLine” as it no longer matters which platform your code is running on.

HTH,
Tim