New Posts  All Forums:Forum Nav:

Python and regex

post #1 of 2
Thread Starter 
Hey guys!
My first time working with regular expressions, programming in python (I know, I know, inb4 python bashing ) and I'm having a little trouble. What I want to do is this:
1. Have a list of searchable words (let's say 4)
2. User inputted search term
3. Use regex to find matches
4. Return words matching pattern

But I don't exactly want what regex offers. For example, if the search words are:
And the search term is '*EST?', the '?' means 'must have one character; can be any character' (the '*' means 'anything'), so no words would return as none of them have 'anything' followed by 'EST' followed by exactly one of any character.
For now, I have that the script converts any '?' with '.+', but for some reason it returns 'BESTNC' as a result, which is not right as 'EST' is followed by more than one character. If it was 'BESTN', returning that would be correct. Makes sense?

Thanks for your input!
post #2 of 2
It works exactly as you defined. ‘+" means 1 or more occurrences then it should return ‘BESTNC’ since 'BESTN' isn’t in the list.
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming