SitePoint Sponsor |
|
User Tag List
Results 1 to 1 of 1
-
Dec 5, 2011, 22:06 #1
- Join Date
- Feb 2011
- Posts
- 34
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
How would you find a certain line in a string of text?
If my string of text that contained something like this
440..john
216..frank
321..Lisa
554..Mandy
How would I pull just the line "321..Lisa". I'm parsing a xml file which is similar to this format. This list is contained inside a single node. The numbers on each line may change frequently so I cannot use split() or replace() from "Lisa". Would regex be the preferable way to approach this situation? If so, I figure I could use regex to check the characters before and after Lisa until a break occurs since a break signfies a new line. How would my regex pattern look? Would it be something like
re.Pattern("\b^<br />.Lisa$\b")
Now say my re.Pattern was correct. How would I extract just that line? Help is much appreciated.
Bookmarks