Regex similar to "^(?u)\w$", but without digits?

John Machin sjmachin at lexicon.net
Sun Apr 12 02:08:08 CEST 2009


On Apr 12, 4:29 am, Andreas <a.pfren... at gmail.com> wrote:
> Hello,
>
> I'd like to create a regex that captures any unicode character, but
> not the underscore and the digits 0-9.

[requirement 1]

> "^(?u)\w$" captures them also.
> Is there a possibility to restrict an expression like "\w" to "\w
> without [0-9_]"?

[requirement 2]

The two requirements are not the same.
R1: [^0-9_] matches any character except the underscore and the digits
0-9
R2: To match "like \w except for underscore and digits 0-9", find
"negative lookbehind assertion" in the re docs.

I've omitted the ^, $ and (?u) because the above advice is general.

HTH,
John



More information about the Python-list mailing list