Reg Ex

janejeba

Member
How to extract the following sub string from input string using regex ?

Extract String : SP123456789.xls

Input String : I'm Indian - I like India - SP123456789.xls

[ The count of extract String always remain fixed but the number pattern will vary ]
 
Last edited:

JackT

New Member
I'd say if the format is stable enough like XXXX - XXXXX - SP123456789.xls.

Then you'd be able to get by string manipulation.

However, to answer the question, regex will be like below if its always two bit of char and nine bit of digs.
Code:
\w{2}\d{9}

It also can be like below if you wanna enforce upper case.
Code:
[A-Z]{2}\d{9}

Cheers,
Jack
 
Top