regex search with a space as the fist character

D

Diez B. Roggisch

Daniel said:
Hello,

None


Why ?

because you start searching at the offset 1, which means you try to find
" u " in "u box2" - and that's not found.

Diez
 
J

Jack Norton

Diez said:
because you start searching at the offset 1, which means you try to
find " u " in "u box2" - and that's not found.

Diez
Couldn't you also just do:
re.compile('^\su')? That would match only if the first character is a
space and the second a 'u'.
I mean, I like to try and have the regexp do it all, instead of forcing
an index, not to mention trying to find the most specific regexp that
works(least generic -- I don't want any false positives). I also do
_not_ like having spaces in the regexp itself. If I need more than one
space I'll use '\s*' or '\s+'.
Also, whats the point of compiling the regexp if you use it only once?

-Jack
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top