"." in Perl regular expressions doesn't include CRLFs?

Find, replace, find in files, replace in files, regular expressions

"." in Perl regular expressions doesn't include CRLFs?

Postby fredtheman » Fri Apr 27, 2012 9:27 am

Hello

I was looking for the following part...

Code: Select all
<h2 class="titleMain">.+?<span>(.+?)</span>

... but UE doesn't seem to include CRLF for the catch all "." character:
Search string '<h2 class="titleMain">.+?<sp...' not found!

Before I upgrade to a more recent release of UltraEdit, I need to make sure that...

  • 15.10 does indeed not support "." as CRLF
  • this issue is solved by the latest release of UltraEdit.
Thank you.
User avatar
fredtheman
Basic User
Basic User
 
Posts: 18
Joined: Sun Sep 05, 2004 11:00 pm

Re: "." in Perl regular expressions doesn't include CRLFs?

Postby Mofi » Fri Apr 27, 2012 9:46 am

Yes, . does not match newline characters. And that has not changed in latest version of UltraEdit.

If . matches newline characters or not is controlled by flag match_not_dot_newline. That is common for all Perl regular expression implementations. Not common is to which value this flag is set by default. In UltraEdit it is set to true (as it is more secure and most often users do not want searches/replaces over multiple lines).

However, it is quite easy to control this flag by starting the search string with (?s). This little expression at the beginning of the search string tells the Boost regular expression library within UltraEdit to use flag match_not_dot_newline with value false for this search/replace.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4049
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: "." in Perl regular expressions doesn't include CRLFs?

Postby fredtheman » Wed May 02, 2012 3:13 am

Thanks Mofi, problem solved.
User avatar
fredtheman
Basic User
Basic User
 
Posts: 18
Joined: Sun Sep 05, 2004 11:00 pm


Return to Find/Replace/Regular Expressions