Saturday, 15 August 2015

python - Require character anywhere in a match -


I'm working on a regex to match F. Supp or F.3d but not june or foobar

By now, I have < Code> [az] []? [Az | Az | \. | ] [A-Z | A-z | \. | | 0-9] + . It's almost there, but it still matches June . Me a . (period character) is required, but I want to allow it to be anywhere in the match.

I think I need to use a positive form, but my effort does not work: (? = [.]) [AZ] []? [AZ | Az | \. | ] [A-Z | A-z | \. | | 0-9] + .

I am using Python.

If you want in your string. You can use the in operand:

  if '.' With the term  

and with regex you can use a positive look-around to make sure that you have dot . in your string:

  ([\ w] +)? (? = \.) ([\ W] +)?  

regular expression view


No comments:

Post a Comment