RegEx Question : OH MIGHTY KEM!!!!

Ok… so why does the 1st need the “*” and the 2nd does not?

btw… that did work… :slight_smile:
meaning I did come up with the right equation, just had extra []

RegExRx generates xojo code, but not only.
it helps you to find the right pattern for the text you want to deal with.
so it is a very useful app even if you don’t use it with xojo !

[quote=286206:@Dave S]Ok… so why does the 1st need the “*” and the 2nd does not?

btw… that did work… :slight_smile:
meaning I did come up with the right equation, just had extra [][/quote]
Because, following the first letter of the string [A-Za-z], you can have 0 or more word characters \w* before the optional period. But, if the period exists, you need 1 or more word characters (\.\w+)?

Without the asterisk, you are saying a letter character followed by a single word character followed by an optional period and word group.

[quote=286208:@Mark Walsh]Because, following the first letter of the string [A-Za-z], you can have 0 or more words \w* before the optional period. But, if the period exists, you need 1 or more words (\.\w+)?

Without the asterisk, you are saying a letter character followed by a single word followed by an optional period and word group.[/quote]
Got it… Thanks… wondering who the sadist was that came up with RegEx format

I’m only peripherally following this discussion among other things, but it sounds like you got it working.

One thing though: The pattern \\w* means, “zero or more ‘word’ characters”, while [\\w*] means, “a single character that may be a ‘word’ character or an '’". Any tokens within a character class (square brackets) represent a single character, and repeaters like “+” or "” are taken literally.

One more thing: Before I recommended that pattern, I tested it first. :slight_smile:

I’m no expert like Kem, but I picked up the basics fairly quickly. As expressions go, this one is fairly simple (the hardest part is often accurately communicating the exact parameters to follow) There are much more complicated forms (lookarounds, characters which have different meanings depending on where they exist) that are a little bit beyond my ability. I can usually write an expression to do what I need (although it might not be as efficient as it could be), but often reading someone else’s I find it hard to determine what it is doing.

Thanks, I knew you’d have the explanation for that. :slight_smile:

[quote=286207:@Jean-Yves Pochez]RegExRx generates xojo code, but not only.
it helps you to find the right pattern for the text you want to deal with.
so it is a very useful app even if you don’t use it with xojo ![/quote]

Thanks Jean-Yves. In fact, RegExRX will let you copy and paste the pattern and code into a variety of languages, not just Xojo. It tests against the PCRE engine which is what Xojo uses, but is also the basis for a variety of implementations.

If you want to become an expert quickly, just write your own regular expression editor/tester.

Wait, no, don’t do that…

:slight_smile:

You might be an expert with Regular Expressions, but I’m wondering about your definition of ‘quickly’