Simple (?) Regular Expression Question

S

Steve Zatz

Is '@' a special character in regular expressions? I am asking
because I don't understand the following:
' *'

Have googled atsign and regular expressions but have not found
anything useful. System is Win XP, Python 2.3.3. Any help would be
appreciated.
 
T

Terry Carroll

Is '@' a special character in regular expressions? I am asking
because I don't understand the following:

' *'

Have googled atsign and regular expressions but have not found
anything useful. System is Win XP, Python 2.3.3. Any help would be
appreciated.

I suck at regular expressions, but I think that what's going on here is
that \b matches an empty string, but only at the start or end of a word.
In the first case ("\b@" and " @"), there is no start-of-word, so no
match, no substitution.

In the second case ("\ba" and " a", you have \b matching the empty string
between the blank and the "a", because the "a" is considered a word.

"a" is going to be considered a word, because it's entirely composed of
letters and numbers (a single letter), while "@" is not.
 

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
474,175
Messages
2,570,946
Members
47,498
Latest member
yelene6679

Latest Threads

Top