0

In this string "13 12", I like to find if there is an occurrence of '3', but I am not interested in char '3' which is part of "13". In other word I am looking for number 3 not 13.
By using the following code in python I always get a match,

match = re.match('3','13 12')

Any help regarding how to find isolated occurrences of characters or sequence of characters will be appreciated.

3
Contributors
2
Replies
4
Views
5 Years
Discussion Span
Last Post by Gribouillis
0
>>> print('3' in  '13 12'.split())
False
>>> print('3' in  '13 12 333 453 2 3 433'.split())
True
0

There is also re.search(r'\b3\b', '13 12 333 453 2 3 433') but it will match -3 too.

Edited by Gribouillis: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.