Topic: How to cross out a string

I need to cross out strings except the last four letters.  The string can have different lengths and have shorter than 4 letters.

For example if a =  "123-456-7890' and b = 'xyz'
Then crossout(a) = "XXXXXXXX7890" and crossout(b) = "XXX"

I'm not very good with regular expressions - can someone help?  Also, what's a good book or site where I can study about regular expressions so I don't have go ask every small question on the forum? smile  For me regexps is such a black art.

Last edited by sthapit (2010-12-07 22:27:52)

Re: How to cross out a string

(\d+)"*$ will get the last digits of your string, everything after the dash. From there, append 'XXXX' and you're good to go.

I've heard good things about a software called Regex Builder. There's also http://www.regular-expressions.info/tutorial.html. If you're a OSX user, I'd highly recommend Reggy. It's a live regex editor and will let you practice with ease.

Best of luck!

Last edited by EricR (2010-12-14 02:32:08)