Questions tagged [regex-alternation]

Anything related to regular expressions alternation operation. An alternation operation in regular expressions syntax is a way of indicating two alternative patterns which can both match the subject string. In many regular expressions flavors (notably those derived from Perl syntax) the alternation is indicated by a vertical bar "|".

Anything related to regular expressions alternation operation. An alternation operation in regular expressions syntax is a way of indicating two alternative patterns which can both match the subject string. In many regular expressions flavors the alternation is indicated by a vertical bar "|".

39 questions
0
votes
2 answers

Python regex: Using Alternation for sets of words with delimiter

I want to match a string for which the string elements should contain specific characters only: First character from [A,C,K,M,F] Followed by a number (float or integer). Allowed instances: 1,2.5,3.6,9,0,6.3 etc. Ending at either of these roman…
kaushal
  • 55
  • 1
  • 8
0
votes
1 answer

Either|Or part of regex for matching two possibilities

We have two ways of referring to the same system: tr12345 fr12345 Right now I have one regular expression per variation, e.g /(?:^|^\s|[^\/a-zA-Z0-9])tr([0-9]+).*$/img /(?:^|^\s|[^\/a-zA-Z0-9])fr([0-9]+).*$/img This works fine, but I thought it…
Tiago
  • 1,984
  • 1
  • 21
  • 43
0
votes
1 answer

Regex alternation optional replace

I would like to make my life translating Objective-C to Swift easier; I'm currently writing a program that will match certain often-used constructions (such as methods, properties and variables) and replace them with the Swift version. Now I'm…
vrwim
  • 13,020
  • 13
  • 63
  • 118
0
votes
4 answers

Priority in regex manipulating

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 between output of the first and output of the second?…
Mohammad Fajar
  • 957
  • 1
  • 12
  • 24
0
votes
1 answer

Regular Expression Trouble with Optional Phrase with Different Formats

I have a file from which I want to parse specific values. How do I put all three of the following regular expressions together to return a single group of entries for each test, whether it has measurements or not and whether it has errors or not AND…
0
votes
1 answer

How to use grep with alternating part of the regular expression?

I want to grep all dates in August or September (date format mm/dd/yyyy with leading zeroes). I tried: grep '0\(8\|9\)/[0-9][0-9]/2012' But command prompt outputs: The system cannot find the path specified.
ljustin
  • 347
  • 1
  • 6
  • 16
-1
votes
2 answers

Find the maximal input string matching a regular expression

Given a regular expression re and an input string str, I want to find the maximal substring of str, which starts at the minimal position, which matches re. Special case: re = Regex("a+|[ax](bc)*"); str = "yyabcbcb" matching re with str should…
Cosinus
  • 31
  • 4
-2
votes
1 answer

How do I instruct Scala's regex matcher to select the leftmost alternation

I have hit a regular expression alternation problem when attempting to retrieve a value from scala.util.matching.Regex. I have tried both the default and the unanchored initialized states while using the findAllMatchIn method. Using the regex…
chaotic3quilibrium
  • 5,661
  • 8
  • 53
  • 86
-2
votes
1 answer

RegEx for capturing digits in a string (PHP)

I am pulling in job numbers and matching them to data in a mysql database, then retrieving the matching data. If my job number is 123456 then it matches up fine and I get results. Some are 123-456 some are 12-text, while some are…
1 2
3