Reputation: 117
I have below string:
Values: Fail.123/urs/temp/lib.000
I need to create a regular expression which will not consider the spaces and "". And It should not be case sensitive also.
If I will pass above string (Values: Fail.123/urs/temp/lib.000)
. it will show the below strings also:
value:Fail.123/urs/temp/lib.000
Value:fail.123 /urs/temp/Lib.000
value:"fail.123 /urs/temp/Lib.000
Upvotes: 0
Views: 119
Reputation: 500317
The following should give you the idea:
In [76]: cmpkey = lambda s:re.sub(r'[\s"]', '', s).lower()
In [77]: cmpkey('Values: Fail.123/urs/temp/lib.000') == key('values:"fail.123 /urs/temp/Lib.000')
Out[77]: True
P.S. I just noticed that in your example, "value" is used interchangeably with "values". Why is that?
Upvotes: 1
Reputation: 17979
The following regular expression will ignore white space and "
(quotes):
[^\s"]*
PS: I tested this using .NET regular expressions but it should work for python
Upvotes: 1