Bug: Regex Search & Replace doesn't work correctly

Post your questions and problem reports here

Moderator: kfury77

Forum rules
Please try to follow these guidelines. This will help to receive faster and more accurate response.

  • Check the Support section of the corresponding product first. Chances are you will find your answer there;
  • Do not create new topics for already reported problems. Add your comments to the existing topics instead;
  • Create separate topic for each problem request. Do NOT post a number of non-related problem reports in a single topic;
  • Give your topic a meaningful title. Titles such as "A question," "Bug report" and "Help!" provide others no clue what your message is about;
  • Include the version number of the software you are using;
  • This is not an official customer support helpdesk. If you need a prompt and official response, please contact our support team directly instead. It may take a while until you receive a reply in the forum;

Bug: Regex Search & Replace doesn't work correctly

Postby pmk65 » Fri Jul 03, 2015 1:10 am

I have a text in the editor:

Code: Select all
abs(x)   Returns the absolute value of x
acos(x)   Returns the arccosine of x, in radians
asin(x)   Returns the arcsine of x, in radians
atan(x)   Returns the arctangent of x as a numeric value between -PI/2 and PI/2 radians
atan2(y,x)   Returns the arctangent of the quotient of its arguments
ceil(x)   Returns x, rounded upwards to the nearest integer
cos(x)   Returns the cosine of x (x is in radians)
exp(x)   Returns the value of Ex
floor(x)   Returns x, rounded downwards to the nearest integer
log(x)   Returns the natural logarithm (base E) of x
max(x,y,z,...,n)   Returns the number with the highest value
min(x,y,z,...,n)   Returns the number with the lowest value
pow(x,y)   Returns the value of x to the power of y
random()   Returns a random number between 0 and 1
round(x)   Rounds x to the nearest integer
sin(x)   Returns the sine of x (x is in radians)
sqrt(x)   Returns the square root of x
tan(x)   Returns the tangent of an angle



and want to do a Search/Replace using this regular expression. "(^.*?)\(.*$", using backreference #1 "$1" as replacement.

RegEx explanation:
Code: Select all
// (^.*?)\(.*$
//
// Options: case insensitive
//
// Match the regular expression below and capture its match into backreference number 1 «(^.*?)»
//    Assert position at the beginning of the string «^»
//    Match any single character that is not a line break character «.*?»
//       Between zero and unlimited times, as few times as possible, expanding as needed (lazy) «*?»
// Match the character “(” literally «\(»
// Match any single character that is not a line break character «.*»
//    Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
// Assert position at the end of the string (or before the line break at the end of the string, if any) «$»


But instead of selecting the first "(" and anything to the end of the line, as expected. It just select/replaces everything to the end of the document.
Looks like search/replace with regular expressions only works on the entire editor content and not line by line.

Program used: WeBuilder 2015 v13.2.0.164
Last edited by pmk65 on Mon Jul 06, 2015 2:54 pm, edited 1 time in total.
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 678
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: Bug: Regex Search & Replace doesn't work correctly

Postby R1R » Mon Jul 06, 2015 10:00 am

If what you want is selecting the first "(" and anything to the end of the line, so try this
Code: Select all
\([^\(]*?^

It finds the first "(" and any character between to the end of the line what is NOT a "(".

Or a simpler verison without checking the characters as NOT a "("
Code: Select all
\(.*?^
R1R
 
Posts: 9
Joined: Thu Oct 23, 2014 11:05 am

Re: Bug: Regex Search & Replace doesn't work correctly

Postby pmk65 » Mon Jul 06, 2015 2:52 pm

R1R wrote:If what you want is selecting the first "(" and anything to the end of the line, so try this
Code: Select all
\([^\(]*?^

It finds the first "(" and any character between to the end of the line what is NOT a "(".

Or a simpler verison without checking the characters as NOT a "("
Code: Select all
\(.*?^


That does work, but it's not very initiative having to add a "^" (beginning of line) at the END!

In UltraEdit (and other RegEx search functions), my regex "(^.*?)\(.*$" is working as expected. It's only in WeBuilder it fails.

IMO: The RegEx search/replace functionality is useless if you can't use "standard" regular expressions, but have to rewrite them into "Blumentals" format.
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 678
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark

Re: Bug: Regex Search & Replace doesn't work correctly

Postby R1R » Mon Jul 06, 2015 5:54 pm

It has only a very basic regex support for simple use. I use http://www.regexbuddy.com.
R1R
 
Posts: 9
Joined: Thu Oct 23, 2014 11:05 am

Re: Bug: Regex Search & Replace doesn't work correctly

Postby Aivars » Thu Jul 23, 2015 10:50 am

Your regular expression is incorrect, you need:
Code: Select all
(^.*?)\(.*?$


.* is greedy match, it will try to grab as much characters as it can (in WeBuilder DOT matches newlines as well, for convenience it has Single-Line and Multi-Line flags on), .*? will match as few as possible.
Blumentals Software Programmer
User avatar
Aivars
Blumentals Software Developer
 
Posts: 2456
Joined: Thu Aug 22, 2002 1:40 pm
Location: Latvia

Re: Bug: Regex Search & Replace doesn't work correctly

Postby pmk65 » Fri Jul 24, 2015 3:26 pm

Aivars wrote:in WeBuilder DOT matches newlines as well...


Ahhh. That was why. Thanks for clearing that up.. :D
There are 10 types of people in the world: Those who understand binary and those who don't.
User avatar
pmk65
 
Posts: 678
Joined: Sun Dec 20, 2009 9:58 pm
Location: Copenhagen, Denmark


Return to HTMLPad / Rapid CSS / Rapid PHP / WeBuilder Support

Who is online

Users browsing this forum: No registered users and 26 guests

cron