Matching 0 or more spaces in searches

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
buk2
Posts: 1
Joined: Fri Aug 18, 2023 11:12 pm

Matching 0 or more spaces in searches

Post by buk2 »

Due dilligence: Looked at all 22 matches from this search: matching spaces in regular expressions; none answered my question.

I want to find all occurances of

Code: Select all

.{space{1+}
that is a comma followed by one or more spaces. I tried (commenserate with other 'perl-compatible" regex engines) a search term of

Code: Select all

,\s+
and got "Cannot find regular expression:..."

(I'd normally post a (cropped)screen grab of the error message at this point; but this forum appparently doesn't support inlining images (despite the [ img][/img ] tags produced by the 'insert image] button above); and life is too short to try and work out what stupid magic is required to do so!).

Please do not suggest I switch to using the (antiquateted; DOA; rediculously verbous and utterly crude) POSIX regex formatting. Once again; life is too short for that...

In every other "Perl-compatible" regex engine (a brief exploration shows that I have 11 at least I use regularly [sic]), \s+ matches 1 or more [space|tab|form feed|line feed|+unicode bollo..s]... Eg.
  1. Javascript:
    \s Matches a single white space character, including space, tab, form feed, line feed, and other Unicode spaces. Equivalent to [ \f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]. For example, /\s\w*/ matches " bar" in "foo bar".
  2. MS .NET
    \s Matches any white-space character. \w\s "D " in "ID A1.3"
  3. rexegg.com summation:
    \s Most engines: "whitespace character": space, tab, newline, carriage return, vertical tab a\sb\sc a b
    c
  4. Java:
    The regular expression \s is a predefined character class. It indicates a single whitespace character. Let's review the set of whitespace characters: [ \t\n\x0B\f\r]
  5. Google Workspaces:
    \s Matches any whitespace character. For example, use this character to specify a space between words in a phrase: stock\stips matches the phrase stock tips
  6. Python:
    \s For Unicode (str) patterns:
    Matches Unicode whitespace characters (which includes [ \t\n\r\f\v]...). If the ASCII flag is used, only [ \t\n\r\f\v] is matched.
    For 8-bit (bytes) patterns: Matches characters considered whitespace in the ASCII character set; this is equivalent to [ \t\n\r\f\v].
  7. (bored now.. look 'em up yourselves!)

    Why doesn't this work in TextPad? (Been using TP since v2.something; now using v5.something. Rretired now, can't afford upgrades.)
Last edited by AmigoJack on Sat Aug 19, 2023 9:23 am, edited 1 time in total.
Reason: linking search; list, code, quote formatting; removing unnecessary line breaks
User avatar
AmigoJack
Posts: 515
Joined: Sun Oct 30, 2016 4:28 pm
Location: グリーン ヒル ゾーン
Contact:

Re: Matching 0 or more spaces in searches

Post by AmigoJack »

buk2 wrote: Fri Aug 18, 2023 11:51 pmLooked at all 22 matches from this search: matching spaces in regular expressions
The board search also supports wildcards and brackets, so you could have found more by searching for matching space* (expressions | regex | regexes). Note that the words "regular", "expression" and "in" are ignored, because they're considered too common to be indexed - that's why I omitted them to begin with (you can see that hint with your search query, tho).
buk2 wrote: Fri Aug 18, 2023 11:51 pmall occurances of

Code: Select all

.{space{1+}
that is a comma followed by one or more spaces. I tried (commenserate with other 'perl-compatible" regex engines) a search term of

Code: Select all

,\s+
and got "Cannot find regular expression:..."
I'm not sure who has TextPad 5 around anymore and if it really advertized its regex support as "Perl compatible". I'll report back when I found my old copy and tried it in a sandbox to reconstruct your issue. Is \s really needed (as in "every kind of space") or would you just need the literal whitespace character? There are alternatives to achieve what you want (unrelated to how often it should match):
buk2 wrote: Fri Aug 18, 2023 11:51 pmthis forum appparently doesn't support inlining images (despite the [ img][/img ] tags
No stupid magic is required, and there's no reason to omit the URI of your picture then. Most people confuse inlining pictures with inlining an entire website (where the picture of interest is merely inlined, too). Again, you have multiple possibilities:
  1. use the picture URI for the [img] BBCode instead of a website URI
  2. under the editor textbox see the tab "Attachments" - use it to upload your file(s) of interest - pictures can then even be inlined in your post wherever you want (otherwise all uploads are still listed with your post)
  3. just post the URI that you thought was the one of the picture - it is automatically turned into a link, so readers can at least click on it
buk2 wrote: Fri Aug 18, 2023 11:51 pm+unicode bollo..s
TextPad 5 had no Unicode support to begin with, so you can't use that as example for what its regex engine should support. Also please consider using BBCode - it is explained and as intuitive as HTML, because your post was hard to read without any formatting at all. Especially codes and quotations should be displayed differently (with code you want to keep whitespaces, instead of getting it interpreted like HTML where multiple spaces are merged into one).
User avatar
bbadmin
Site Admin
Posts: 854
Joined: Mon Feb 17, 2003 8:54 pm
Contact:

Re: Matching 0 or more spaces in searches

Post by bbadmin »

TextPad 5's regular expressions are not Perl compatible. Its regular expressions are based on the ones used at that time by grep in Unix.

Zero or more horizontal space characters can be matched using "[ \t]*".

Upgrades are available at a discount. Contact sales for more information.
Post Reply