g1smd

msg:4500372 | 8:33 pm on Sep 26, 2012 (gmt 0) |
One thing you need to make sure you avoid is excessive backtracking: [regular-expressions.info...]
|
lucy24

msg:4500438 | 12:13 am on Sep 27, 2012 (gmt 0) |
You left out one rather crucial bit of information: a variable in what? Obviously not in HTML itself; it doesn't speak RegEx and isn't technically a language at all. No two languages speak exactly the same RegEx dialect. Many programs distinguish between single-line and multi-line mode: the ^ and $ anchors can refer either to the very beginning and end of the whole document, or to every single line break. | The string im trying to pick out is between a div and its closing tag. |
| Er, you mean the string is within the div? i.e. between its opening and closing tags? Do you know anything about what's inside the div, like what other tags might occur? I'm thinking something like
<div class = "blahblah">(([^<]*</?(?:p|i|span)(?: class = "\w+(?: \w+)*")?>)*[^<]*)</div> but don't take my word for it without counting parentheses on your own fingers. If there are subsidiary divs, nest deeper. It can still be done. Tip: "Disable graphic smile faces for this post" will look as if it isn't working in Preview, but in the real post it's just what you need. "Code" tags achieve the same purpose.
|
santapaws

msg:4500874 | 10:14 pm on Sep 27, 2012 (gmt 0) |
thanks for the replys. I am trying use regex to store variables in winautomation. I managed to sort the original problem by adding a '?' to the end of (.|\n)*. Lucy thanks for the code. I will try and understand it and use that.
|
swa66

msg:4500883 | 10:57 pm on Sep 27, 2012 (gmt 0) |
I've no clue what type of regexps "winautomation" uses (whatever it is). In perl regular expression: *? is typically an ungreedy match instead of the default greedy match. e.g.: data: = "mississippi"; regexp = "/(i.*s)/" would give "ississ" data = "mississippi"; regexp = "/(i.*?s)/" would give "is" There's a modifier to treat the data as a whole as one line it's "m": data= "a\nb\nc\n" regexp = "/a\nb/m" would match The easier way to deal with complex data is to parse the html as xml ... but that requires good xhtml which is far too rare. That's how I do things - it's also much more efficient than very complex regexps will be.
|
santapaws

msg:4501692 | 6:57 pm on Sep 29, 2012 (gmt 0) |
swa66 thanks for that. Winautomation is a macro builder for guys like me who cant program.
|
|