python - Regular expression for matching numbers and strings -


I have a series of words below

  476pe e586 99 99 rrr ABCF   

I have to write a regular expression that will match letters and numbers to characters. From the above stars, I only need to match

  476pe e586 99 99  << Pre>  ^ [\ D] * [0-9] + [\ D] * $   

I tried writing the regular expression below <

but this does not work, I have an online regax tool , And it shows that the entire string is matching.

The problem with your regex is that \ D excludes any number can be anything , so that will match the character with special characters incorrectly, and will fail to match the stars with more than one, instead, ^ [0 -9a-zA-Z] * [0-9] [0-9A-ZA-ZE] * $ . It will match any number of numbers or letters, after a number and then any number of numbers and letters will match.

And here one ...

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -