Questions tagged [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 "|".

42 questions
0
votes
4 answers

Example of (a|b)* about Alternation , I am confused , Why are ab, ba in the result set?

Alternation is about Union, then if We have R={"a"} , S={"b"} , then R|S will be {"a", "b"}. Why ab, ba are included there in (a|b)*? I don't understand why Regular Expresion wikipedia I think the result set should be (a|b)* = {Ɛ,"a", "b",…
christianbueno.1
  • 516
  • 1
  • 8
  • 12
0
votes
2 answers

How to do Perl regex with alternation and substitution

I wish to transform "eAlpha eBeta eGamma" into "fAlpha fBeta fGamma." Of course this is just a simplified example of more complex substitutions. Here is my perl program: my $data= "eAlpha eBeta eGamma"; $data=~…
Cab
  • 11
  • 2
0
votes
2 answers

How can I filter for multiple object identifiers using the equivalent of wildcards or alternation in jq?

Summary I have a working jq filter which correctly parses three different name and payload objects and massages them into the desired output format. The problem is that I'm having to express each object path explicitly, as I can't see to find a way…
Todd A. Jacobs
  • 81,402
  • 15
  • 141
  • 199
0
votes
1 answer

Alternating Repeating Countdown - html - javascript

Obviously this question has multiple parts : one to get a countdown and one to alternate which to display. I want a countdown to the weekend (Saturday 00:00) and on the weekend it will display a countdown to the end of the weekend (Monday 00:00) So…
CharlieG
  • 38
  • 10
0
votes
1 answer

How can I use grep to retrieve two patterns within the same fixed-length sections of text?

I'm trying to extract information from a file using grep and make connections between related occurrences. For example, my file may contain the following repeated pattern: Section Info1 etc etc Info2 I want to be able to grep for Section and grab…
Big Ali
  • 217
  • 1
  • 8
0
votes
1 answer

WPF Alternation and selected background color doesn't work together

I struggle with Alternation style and selected row background color style in ListViewItem. I could make that they work separately, but together they does not work. Maybe someone know problem? Code:
LTU
  • 195
  • 1
  • 3
  • 18
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
1 answer

How to define this regex with alternation to have the same number of groups in the match?

I am trying to parse such strings 99_GOG_A_X1_FOO X-2014-09 99_YAK_A_YZ1_BAR YZY-2014-10 with this regex 99_\w{3}_(A|B)_((X)(0*[1-9][0-9]?)_(FOO|BAR) X-(\b0*20(1[4-9]|[2-9][0-9])\b)-\b0*([1-9]|1[0-2])\b|(YZ)(0*[1-9][0-9]?)_(FOO|BAR)…
mrt181
  • 5,080
  • 8
  • 66
  • 86
0
votes
1 answer

check alternation maxima minima in matlab

I have written an algorithm that finds the local maxima and minima in a signal. [id_max, id_min] = find_max_min(signal); I would like now to check: if the alterantion of maxima and minima is respected i.e.…
gabboshow
  • 5,359
  • 12
  • 48
  • 98
0
votes
1 answer

Alternation gives unexpected result

In Ruby, try to extract some patterns from a long string and put each matched pattern into an array of string. For example, the long string input can be "\"/ebooks/1234.pdf\" \"/magazines/4321.djvu\"" The expected result is ["/ebooks/1234.pdf",…
George
  • 3,384
  • 5
  • 40
  • 64
0
votes
2 answers

How to make alternating turns in Java?

I'm in 9th grade in AP computer science and we were given a project to make a game. I picked a simple Game of Chi thing that my teacher had suggested. But what I cannot figure out is how to make alternating turns between the computer and the…
user2962905
  • 3
  • 1
  • 1
  • 2
0
votes
1 answer

Regex to replace the words alternatively

I was working on the file names to give alternative names. i.e. I have some duplicate or repetitive names. This is the input: image thisismyimage image image anotherimage I was looking for a solution to give alternative names to all…
Alex Ms
  • 613
  • 2
  • 7
  • 8
1 2
3