Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Regular Expression - Predefined Character Class (.)  RSS feed

 
Bruce Jin
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!
 
John de Michele
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.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!