Do regular expressions work?

The popular SciTE-based AutoHotkey Script Editor
LAPIII
Posts: 669
Joined: 01 Aug 2021, 06:01

Do regular expressions work?

03 May 2024, 10:45

I've got version 3.1.00 in Replace this is what I did:
  1. In the "Find" field, enter the regular expression: ^.LocalizedType:.$ (This will remove 'LocalizedType:' and everything after it on each line in the file.)
  2. Leave the "Replace" field empty.
  3. Make sure the "Regular expression" option is checked.
  4. Click "Replace All".
I received an error that read "No replacements because string '*.LocalizedType:.$' was not present.".
User avatar
boiler
Posts: 17173
Joined: 21 Dec 2014, 02:44

Re: Do regular expressions work?

04 May 2024, 02:45

LAPIII wrote: This will remove 'LocalizedType:' and everything after it on each line in the file.
It will not — mainly because of your incorrect use of the wildcard.

Does it have some option that you set where the ^ and $ anchor tokens are relative to individual lines? If not, then it would only match once in the whole file.

And your pattern is not correct anyway, which is why it is not found even once in the file. You seem to think that . is a wildcard that matches any number of characters. It does not. It matches exactly one character. To have it match any number of characters (zero or more), then you would need to add the * quantifier to make it .*. Without that, you are saying that it needs to be preceded by exactly one character after the start of the haystack and followed by exactly one character between it and the end of the haystack. And again, unless there is some special setting for it, the haystack is the entire file, not an individual line. You can accomplish what you are attempting by using \V instead of . to match non-line break characters (still with a * quantifier).

Return to “SciTE4AutoHotkey”

Who is online

Users browsing this forum: No registered users and 12 guests