- 1

What would [a^]* match?

The meta character * means "zero or more repetitions of the previous thing". It tries to match as many repetitions as possible. The "previous thing" can be a single character, a class, or a group of characters in parentheses. But Here we can use brackets instead of parenthesis The answer is Zero or more repetitions of "a" or "^" can you explain ?

18th Nov 2018, 12:16 PM
K Mayuri
K Mayuri - avatar
4 odpowiedzi
+ 4
The [] are used to signify character classes. These literally match either of the characters present in them. A metacharacter present in a character class is treated just like any other character. Eg : [d+] matches d or +, but (d+) matches one or more occurrences of d. There are some characters, however, that act as metacharacters only when used in certain positions. Eg : caret(^), when used as the first character, creates a negated character class. This means that all characters are matched except the ones inside. Other metacharacters include hyphen(-) between two characters, and \ for escaping these metacharacters themselves. Metacharacters can be used on character classes in the same way as groups.
18th Nov 2018, 1:27 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 2
What would [a^]* match? Answer :- Zero or more repetitions of "a" or "^"
29th Jun 2020, 5:46 AM
Gourav Tomar
Gourav Tomar - avatar
+ 1
20th May 2020, 4:24 AM
I am a coder
+ 1
Fill in the blanks to create a pattern that matches strings that contain one or more 42s. Answer :- r"(42) +
quot; because + metacharacter means "one or more repetitions"
29th Jun 2020, 5:50 AM
Gourav Tomar
Gourav Tomar - avatar