Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Regular Expression - Predefined Character Class (.)  RSS feed

 
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Predefined Character Classes
. Any character (may or may not match line terminators)

I cannot figure out this 'may or may not match line terminators'

I have a regex: "aaa .+?bbb" witch matches

aaa xxxxxx bbb

But it will not match

aaa
xxxxxx
bbb


because of the line breaks.

So what Regex will match the above three lines?
Thanks!
 
Rancher
Posts: 600
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bruce:

The javadoc for the Pattern class should be useful, especially the DOTALL flag.

John.
 
Bruce Jin
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks John.

DOTALL is cool!

(?s)aaa .+?bbb

works.

 
The fastest and most reliable components of any system are those that are not there. Tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!