sarathi Posted August 2, 2009 Share Posted August 2, 2009 I was wondering how I can replace a word, starting from a $ sign, until the first space after it? Quote Link to comment Share on other sites More sharing options...
Garethp Posted August 2, 2009 Share Posted August 2, 2009 Use this pattern '/\$(.*?)\s$/'; Here's something for some reading up http://www.regular-expressions.info/anchors.html The $ normally signifies the end of a string, so you have to escape it when you want to use it as an alphanumeric character Quote Link to comment Share on other sites More sharing options...
sarathi Posted August 2, 2009 Author Share Posted August 2, 2009 Thank you for your help, I changed the code a bit to fit my needs: '~\$([a-z]*?)(?![a-z])~' But I'm wondering how I can add a-z and 0-9? Quote Link to comment Share on other sites More sharing options...
Garethp Posted August 2, 2009 Share Posted August 2, 2009 Instead of [a-z] use [a-zA-Z0-9]. That matches Lowercase, Uppercare and Numerals Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.