samsmithnz Posted June 2, 2005 Posted June 2, 2005 I have a string: "Remote Company 10LC" How would I use Regex to extract the 10LC? Quote Thanks Sam http://www.samsmith.co.nz
Leaders snarfblam Posted June 2, 2005 Leaders Posted June 2, 2005 Do you have a list of strings that you want to process? To use regex like that you would really need a more general format. Do you want to extract the last four chars in a string? Any occurances of two digits followed by two letters? The third word in each string? Quote [sIGPIC]e[/sIGPIC]
samsmithnz Posted June 2, 2005 Author Posted June 2, 2005 Its a really long string, and I want to extract a couple key expressions, such as the example above. I guess I need to 1. Check that the expression exists 2. Extract it. 3. Replace the expression with something more meaningful. For example, I have a paragraph (it's an error message), and I want to replace: "Remote Company 10LC" with "London" Quote Thanks Sam http://www.samsmith.co.nz
michael_hk Posted June 3, 2005 Posted June 3, 2005 Seems the String.IndexOf and String.Replace functions are enough to do the job. Quote There is no spoon. <<The Matrix>>
samsmithnz Posted June 3, 2005 Author Posted June 3, 2005 Of, IndexOf, is plenty enough, but I was just asking if there was a better way to do it with Regex, as I'm replacing quite a few of these strings in a body of text. Quote Thanks Sam http://www.samsmith.co.nz
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.