You are here: PSPad forum > English discussion forum > Complete PCRE Support for RegExps?

Complete PCRE Support for RegExps?

Goto Page: 1 2 Next

#1 Complete PCRE Support for RegExps?

Posted by: kielschwein | Date: 2018-06-03 22:44 | IP: IP Logged

Hi,
I'm wondering, why non capturing submatches don't work (causing a "invalid RegExp" error).
Is this a bug or just a missing feature?
Thanks
kielwschein

Options: Reply | Quote | Up ^


#2 Re: Complete PCRE Support for RegExps?

Posted by: pspad | Date: 2018-06-04 04:10 | IP: IP Logged

Hello
Can you give us any example of nonworking regular expression?
Have you look at PSpad help? Chapter Menu description / Search Menu / Regular epressions?

Options: Reply | Quote | Up ^


#3 Re: Complete PCRE Support for RegExps?

Posted by: kielschwein | Date: 2018-06-04 09:07 | IP: IP Logged

Hi,
any non caturing submatch RegExp causes the error popup
"your regular expression is not correct" (in my case the text is in German).

Here my original example
(.*?\s)(\d+)(?:\.)*(\d+)(,)*(\d+\s)(€|kWh|Cent)

but even this simple one fails
(?:\.)

Both RegExps pass any RegExp (Tester) I've tried, like "Regex Coach", "www.regexpal.com" or "UltraEdit".

Thanks kielschwein

Options: Reply | Quote | Up ^


#4 Re: Complete PCRE Support for RegExps?

Posted by: pspad | Date: 2018-06-04 09:16 | IP: IP Logged

PSPad uses Perl syntax. Substitution is made by $n
Read please help, there are examples (F1 in search dialog should work too)
Or click on the buttons next to search or replace fields

Can you please provide sample text line and write what do you want to search?

Edited 1 time(s). Last edit at 2018-06-04 09:17 by pspad.

Options: Reply | Quote | Up ^


#5 Re: Complete PCRE Support for RegExps?

Posted by: pspad | Date: 2018-06-04 09:19 | IP: IP Logged

(?:\.) isn't correct expression

If you want to search for ?, you need to escape it, cause ? is control char. Same with :

Options: Reply | Quote | Up ^


#6 Re: Complete PCRE Support for RegExps?

Posted by: kielschwein | Date: 2018-06-04 09:31 | IP: IP Logged

Sorry, but I don't understand what you mean with
"(?:\.) isn't correct expression"

This is for sure correct and is a non capturing group subsearch for a DOT.

In fact this does work in all tested example environments besides PSPad.

Here the example:
Text to search and replace

Kaufpreis (netto) 23.648,74 €

Search patter
(.*?\s)(\d+)(?:\.)*(\d+)(,)*(\d+\s)(€|kWh|Cent)

Replace pattern
$1;$2$3$4$5$6

Result text
Kaufpreis (netto) ;23648,74 €

Options: Reply | Quote | Up ^


#7 Re: Complete PCRE Support for RegExps?

Posted by: pspad | Date: 2018-06-04 09:45 | IP: IP Logged

For example:
search for: ^(.*)\s(\d+)\.(\d+)(.*)
replace: $1 ;$2$3$4

Options: Reply | Quote | Up ^


#8 Re: Complete PCRE Support for RegExps?

Posted by: kielschwein | Date: 2018-06-04 10:06 | IP: IP Logged

The issue/my issue is simple that I'm often using complex search/replacement strings and just want to use non capturing subpatterns (to minimze the number of capture groups.
As non capturing groups are part of the PCRE implmentation, I was just wondering, why they don't work in PSPad.

The issue is not just the mentioned example (which does not only search/replace the one supplied text) but a complete set of lines

Options: Reply | Quote | Up ^


#9 Re: Complete PCRE Support for RegExps?

Posted by: pspad | Date: 2018-06-04 10:24 | IP: IP Logged

OK. Change your search expression to: (.*?\s)(\d+)(\.)*(\d+)(,)*(\d+\s)(€|kWh|Cent)
I don't understand this part in your expression: (?:\.)
What do you meant with this one?

Options: Reply | Quote | Up ^


#10 Re: Complete PCRE Support for RegExps?

Posted by: kielschwein | Date: 2018-06-04 10:41 | IP: IP Logged

(?:...) is a non-capturing group, which groups multiple tokes together without creating a capture group

In my case,
(?:\.)
means, search for a DOT as group subpattern, but don't capture it

For details see the following article
[url]stackoverflow.com/questions/3512471/what-is-a-non-capturing-group-what-does-do[/url]

Edited 2 time(s). Last edit at 2018-06-04 10:46 by kielschwein.

Options: Reply | Quote | Up ^


Goto Page: 1 2 Next





Editor PSPad - freeware editor, © 2001 - 2024 Jan Fiala, Hosted by Webhosting TOJEONO.CZ, design by WebDesign PAY & SOFT, code Petr Dvořák, Privacy policy and GDPR