![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Regex Question Hello there, I am a little bit confused by a regex I need to run on some strings... basically I want to match it all "file:// .... .xls" occurrences, but only the ones that do NOT start or end with a " (quote). The reason for that is basically I want to find pure text occurrences of a file://-link within a html file, and not the ones that are <a href="file:\ \....xls">abc</a> ones... Does anyone maybe know from the top of his/her head what the correct regex would be in this situation? Cheers and thanks, -Jörg |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Regex Question On Dec 10, 10:20*am, Joerg Battermann <j...@xxxxxx> wrote: Quote: > Hello there, > > I am a little bit confused by a regex I need to run on some strings... > basically I want to match it all "file:// .... .xls" occurrences, but > only the ones that do NOT start or end with a " (quote). The reason > for that is basically I want to find pure text occurrences of a file://-link > within a html file, and not the ones that are <a href="file:\ > \....xls">abc</a> ones... > > Does anyone maybe know from the top of his/her head what the correct > regex would be in this situation? > > Cheers and thanks, > -Jörg Beware, though -- XML and XHTML (and maybe HTML?) allow the use of single-quoted attributes, too. So you might have to change the regex to [^'"](file://.+\.xls)[^'"] or something similar. |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Regex Question On Dec 10, 4:26*pm, Dathan <dat...@xxxxxx> wrote: Quote: > On Dec 10, 10:20*am, Joerg Battermann <j...@xxxxxx> > wrote: > Quote: > > Hello there, Quote: > > I am a little bit confused by a regex I need to run on some strings... > > basically I want to match it all "file:// .... .xls" occurrences, but > > only the ones that do NOT start or end with a " (quote). The reason > > for that is basically I want to find pure text occurrences of a file://-link > > within a html file, and not the ones that are <a href="file:\ > > \....xls">abc</a> ones... Quote: > > Does anyone maybe know from the top of his/her head what the correct > > regex would be in this situation? Quote: > > Cheers and thanks, > > -Jörg > I think something like [^"](file://.+\.xls)[^"] should do the trick. > Beware, though -- XML and XHTML (and maybe HTML?) allow the use of > single-quoted attributes, too. *So you might have to change the regex > to [^'"](file://.+\.xls)[^'"] or something similar. does not. With .+, if you have multiple occurrences of "file://.......xsl" on a single line, it'll include the first file:// and the last .xls and everything between as a single match. ~Dathan May need to change this to [^'"](file://.+?\.xls)[^'"] to turn off greedy matching. (I think that's the correct syntax |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Regex Question Joerg Battermann wrote: Quote: > I am a little bit confused by a regex I need to run on some strings... > basically I want to match it all "file:// .... .xls" occurrences, but even four: http://en.wikipedia.org/wiki/File_URI_scheme Andrew |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Regex Question "Dathan" <dathan@xxxxxx> wrote in message news:a52d02e6-53b9-4bff-83b5-018f6cbd89a0@xxxxxx Quote: Quote: >> I think something like [^"](file://.+\.xls)[^"] should do the trick. >> Beware, though -- XML and XHTML (and maybe HTML?) allow the use of >> single-quoted attributes, too. So you might have to change the regex >> to [^'"](file://.+\.xls)[^'"] or something similar. Quote: > May need to use .+? instead of .+, as .+ does greedy matching and .+? > does not. With .+, if you have multiple occurrences of > "file://.......xsl" on a single line, it'll include the first file:// > and the last .xls and everything between as a single match. quotation mark you match the first time, you match the second time. Don't ask me for the syntax, I don't remember; I just know it exists. The other thing that came to my mind when I saw this question was maybe it will require lookahead/lookbehind. But maybe that's overkill in this situation. |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Simple regex question | PowerShell | |||
| Re: Simple Regex Question | PowerShell | |||
| Regex Question | PowerShell | |||
| Regex multiline question | PowerShell | |||
| Regex question | PowerShell | |||