Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Search within IDE using Regex non greedy (lazy)?


This question is answered.


Permlink Replies: 4 - Last Post: Jul 2, 2016 3:59 PM Last Post By: Fred Schetterer
Fred Schetterer

Posts: 83
Registered: 5/20/99
Search within IDE using Regex non greedy (lazy)?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 30, 2016 10:46 AM
Hi,

Pretty new to Regex but I can't get any of these to work in the IDE:

MyFunc\((.+?)\)
MyFunc\(([\w]+)\)

The Test string is: (MyFunc(Value) + whatnot)

If I use MyFunc\((.+)\) it selects the entire string.

Yet all this works fine using TRegEx..
Peter Below

Posts: 1,227
Registered: 12/16/99
Re: Search within IDE using Regex non greedy (lazy)?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 30, 2016 11:17 AM   in response to: Fred Schetterer in response to: Fred Schetterer
Fred Schetterer wrote:

Hi,

Pretty new to Regex but I can't get any of these to work in the IDE:

MyFunc\((.+?)\)
MyFunc\(([\w]+)\)

The Test string is: (MyFunc(Value) + whatnot)

If I use MyFunc\((.+)\) it selects the entire string.

Yet all this works fine using TRegEx..

The IDE editor uses a different regular expression engine, it predates
the appearance of TRegEx in the RTL by many years. It uses a slightly
different syntax. YOu select greedy behaviour by using the "maximal
match" checkbox in the search dialog, not by using a specific syntax in
the regex itself.

--
Peter Below
TeamB

Fred Schetterer

Posts: 83
Registered: 5/20/99
Re: Search within IDE using Regex non greedy (lazy)?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 30, 2016 11:27 AM   in response to: Peter Below in response to: Peter Below
Peter Below wrote:
using the "maximal match" checkbox in the search dialog

Hmm, and where is that?

I don't see it in:
Search>Find (not a Dialog)
Search>Find in Files
Search>Replace
Peter Below

Posts: 1,227
Registered: 12/16/99
Re: Search within IDE using Regex non greedy (lazy)?
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 1, 2016 10:08 AM   in response to: Fred Schetterer in response to: Fred Schetterer
Fred Schetterer wrote:

Peter Below wrote:
using the "maximal match" checkbox in the search dialog

Hmm, and where is that?

I don't see it in:
Search>Find (not a Dialog)

My bad, sorry. I'm still using the good old CodeWright editor for
complex regular expression search and replace operations, and the
feature I mentioned is actually in its Search dialog. The IDE has no
way to specify greedy or lazy behaviour.

See
http://docwiki.embarcadero.com/RADStudio/Berlin/en/Regular_Expressions
for a description of the syntax the IDE search feature recognizes. That
is a lot less than TRegEx understands, unfortunately.

--
Peter Below
TeamB
Fred Schetterer

Posts: 83
Registered: 5/20/99
Re: Search within IDE using Regex non greedy (lazy)?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jul 2, 2016 3:59 PM   in response to: Peter Below in response to: Peter Below
{quote:title=Peter Below wrote:}

Thanks, filed this issue: https://quality.embarcadero.com/browse/RSP-15402
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02