Regular expression enhancements

Post feature requests, product enhancement ideas, and other product-specific suggestions here. Do not post bug reports.
Forum rules
Do not post any licensing information in this forum.
This topic is 11 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
abqbill
Posts: 138
Last visit: Mon Sep 28, 2020 1:20 pm

Regular expression enhancements

Post by abqbill »

It seems that the regular expression engine doesn't support backreferences (references to grouped items in the search pattern). Consider this file:

Code: Select all

Line 1
Line 2
Line 3
Suppose I want to place the numbers at the beginning of each line, rather than the end. I would normally use find/replace patterns like this:

Find: (Line) ([0-9])$Replace: 2 1After this replacement, the file would look like this:

Code: Select all

1 Line
2 Line
3 Line
The numbers in the replacement text refers back to the grouped expressions in the find string (expressions grouped by parentheses).

Also, it appears that it is possible to use control codes (n, etc.) but these appear not to be documented. (IIRC, the manual mentions /n, but I think it's supposed to be n.)It would also be useful if the control codes (n, etc.) worked when searching. IIRC, it appears they only work when replacing, and only when you select the "Use control codes" check box.

Thanks!

Bill
User avatar
birnamdesigns
Posts: 6
Last visit: Wed Aug 29, 2007 2:50 am

Regular expression enhancements

Post by birnamdesigns »

I've also tried this with $n for backreferences (instead of n) and had similar results. It's almost like the 'replace' function is pure text and not hooked into a regex engine at all, despite working with a regex 'find'.in addition to AbqBill's comments:I would like to see multi-line find/replace fields. Why only have multi-line in the file replace dialog?Also, I would like to see a persistant dialog box. I hate that it goes away after the first find. (yes, I am aware that F3 will do a "find next" but that doesn't like me easily compare my regex against what it is matching if I'm trying to debug a regex) Optimally, the search dialog would retain focus during the search, so that hitting <enter> would continue to trigger the "find" button so that it acts as a "find next", and that <escape> would exit the dialog box.For what it's worth, I consider EditPad Pro to have my favorite find/replace implementation.
User avatar
donj
Posts: 416
Last visit: Thu May 29, 2008 5:08 am

Regular expression enhancements

Post by donj »

Thanks for all the input, gentlemen. We'll add this to the internal wishlist.
User avatar
abqbill
Posts: 138
Last visit: Mon Sep 28, 2020 1:20 pm

Regular expression enhancements

Post by abqbill »

Hi Alex, any movement on this request?Thanks,Bill
User avatar
Alexander Riedel
Posts: 8489
Last visit: Thu Apr 18, 2024 9:59 am
Answers: 20
Been upvoted: 37 times

Regular expression enhancements

Post by Alexander Riedel »

The next version of PrimalScript uses a different engine for regular expressions. We will see what becomes available with that.

Alex
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
jakfrost
Posts: 1
Last visit: Wed Jan 27, 2010 2:32 am

Regular expression enhancements

Post by jakfrost »

PrimalScript 2009 DeficiencyI just downloaded the trial of PrimalScript 2009 and I was shocked to find that a script editor did not have usable Regular Expression search and replace capability. There is the search capability but it is almost useless without the appropriate replacement capability. That seems like a huge oversight from a product that I've heard about for many years from work friends but never bothered to try myself. Please address this for the next version if you wish to entice more people to use your product.Regular ExpressionsWikipedia -
Regular Expressions
Regular-Expressions.info
Just a few suggestions about implementing Regular Expression syntax. I would recommend that you look at how the TextPad application implements most of the regular expression functionality for the search functions but doesn't do everything either. Please choose a full featured Regular Expression Library to provide all or as many of these Regular Expression features as possible.Anchors "^ $"Flags for Multi-line, Global, and Case Insensitive "m g i"Quantifiers ". ? * + {n} {n,} {n,m}"Quantifiers Lazy / Non-Greedy " *? +? {n,m}?"Possessive Quantifiers "*+ ?+ ++ {n,m}+"Alternation "(this|that)"Capturing Groups "(catch)"Shy Groups / Non-Capturing "(?:catch)"Look-Ahead / Look-Behind "(?=catch) (?!catch) (?<=catch) (?<!catch)"Conditionals "(?(?=catch)then|else)"Back-references "1, 2,... 11" with more than 9 references.Special Characters "t, n, x00, 00"Character Classes "[:alphanum:]" for (0-9a-z)Equivalence Classes "[[=e=]]" for (e, é, ê)Negated Classes "[^[:alphanum:]]"Regular Expression LibrariesUse a good and popular Regular Expression library. Below is a good reference to help you choose.Wikipedia - Comparison of Regular Expression EnginesThe PCRE library is pretty good and has good support so look at that one.Replacement ExpressionsAdditionally, look at supporting all the replacement options, including character case changing with L, U and E options. Also have the replacement text field be a fillable drop-down field that remembers your previous replacement expressions since some of the ones that are used regularly become quite long and burdensome to retype every time you want to use them.Extended Regular Expression Syntax (POSIX Syntax)Most importantly offer a checkbox in the Preferences to allow the user to use either the POSIX Extended Regular Expression Syntax "(catch)" or the Basic Regular Expression syntax "(catch)" since some folks are used to one or the other syntax, with POSIX Extended Regular Expression Syntax being the more popular standard being the default.
User avatar
abqbill
Posts: 138
Last visit: Mon Sep 28, 2020 1:20 pm

Regular expression enhancements

Post by abqbill »

It appears that PS 2012 still does not support backreferences when replacing strings using regular expressions.

If this is not correct, please tell us how to use them.

If it is correct, I would like to reiterate this feature request.

Thanks,

Bill
This topic is 11 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked