regex-alternation Questions

3

Solved

Is (a|b)* the same as a*|b*? In other words, does (a|b)* accept string which are combinations of as and bs?
Thurmond asked 15/7, 2014 at 17:48

1

Solved

Raku's regexes are expected to match longest token. And in fact, this behaviour is seen in this code: raku -e "'AA' ~~ m/A {say 1}|AA {say 2}/" # 2 However, when the text is in a variabl...
Radioman asked 17/10, 2020 at 21:43

2

Solved

With perl (and almost any regex flavour), every group is numbered sequentially. So for example, this code: 'bar' =~ m/(foo)|(bar)/; print $1 // 'x'; # (1-based index) print $2 // 'x'; # (1-based i...
Resistive asked 16/10, 2020 at 19:1

2

It seems that using a character class is faster than the alternation in an example like: [abc] vs (a|b|c) I have heard about it being recommended and with a simple test using Time::HiRes I verified...

1

Solved

I am using ruby 2.1, but the same thing can be replicated on rubular site. If this is my string: 儘管中國婦幼衛生監測辦公室制定的 And I do a regex match with this expression: (中國婦幼衛生監測辦公室制定|管中) I am expecti...
Damiano asked 26/8, 2014 at 17:13

4

Solved

I write some java code to split string into array of string. First, I split that string using regex pattern "\\,\\,|\\," and then I split using pattern "\\,|\\,\\,". Why there are difference betwee...
Crypto asked 7/8, 2014 at 9:51

2

Solved

I set up a complex regex to extract data from a page of text. For some reason the order of the alternation is not what I expect. A simple example would be: ((13th|(Executive |Residential)|((\w+) )...
Kweichow asked 21/5, 2014 at 12:23

5

Solved

I ran into a small problem using Python Regex. Suppose this is the input: (zyx)bc What I'm trying to achieve is obtain whatever is between parentheses as a single match, and any char outside as...
Shaylyn asked 6/1, 2013 at 12:55

2

Solved

Trying to write a regex matcher for roman numerals. In sed (which I think is considered 'standard' for regex?), if you have multiple options delimited by the alternation operator, it will match the...
Goulash asked 23/12, 2010 at 2:5
1

© 2022 - 2024 — McMap. All rights reserved.