And print (re search (' ABC * g ', 'abcdefg)) but this does not match
CodePudding user response:
'ABC * g'Refers to any number of ABC behind c, c can be 0 to any one, the first 'is actually matches the ABC, ABC * instead of abcdefg
CodePudding user response:
Print (re. Search (' ABC * ', 'abcdefg)) and print (re) search (' ABC. * g', 'abcdefg)) matchingPrint (re. Search (' ABC * g ', 'abcdefg)) does not match the
===========
This is to belong to the basic rules for regular expression!
* represents any (may be zero, one or more)
Number to represent any character.
'ABC * g' representatives can be: abg, abcg, abccg, ABC... CG
So and 'abcdefg mismatch is normal!
CodePudding user response:
Re search (' ABC. * g ', 'abcdefg')Is the cause of the match ". "represents all of the characters, and matches from D to F, in fact not G also can match, or the use of the *