Kitz Forum

Chat => Tech Chat => Topic started by: Weaver on January 14, 2018, 04:12:10 PM

Title: Regex weirdness
Post by: Weaver on January 14, 2018, 04:12:10 PM
I have a regex which works, it matches test data as expected:
    [-:;]

ie match hyphen, colon or semicolon. Despite the special meaning of hyphen to indicate ranges, I believe this is ok because the hyphen is at the start. Anyway, it does behave as expected. As a sanity check I looked at it using this superb tool, which I use a lot: https://regex101.com (https://regex101.com)

So, I later wanted to alter it for a different circumstance to not try and match hyphens:
    [:;]

but for some unknown reason this now does not match against my input. The tool says it should work against my exact data.

My question: Is there something wrong about this second form?

Confession: The above isn’t the entire actual regex, the real thing and also its test data are quite long but this shows the only change made to the regex, so I reduced it down for ease of presentation. Explanation as to why this should be fair is as follows.

These alternative forms both do work though

    [;:]
    [\:;]


I am using the Workflow interpreted language for iOS. These regexes are in a program that I have written in Workflow.