![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | Simple regular expression question Hi, I'd like to write a regexp that finds matches to all URLs (strings) that have the following: http://ads.[domain].com whereas: domain can be any domain name. com - can be any extension (com, co.uk, it...) Any ideas? Thanks, Gabi, |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Simple regular expression question Gabriela schrieb: Quote: > Hi, > > I'd like to write a regexp that finds matches to all URLs (strings) > that have the following: > http://ads.[domain].com > whereas: > domain can be any domain name. > com - can be any extension (com, co.uk, it...) Dim sTest : sTest = Join( Array( _ "Assuming your data is like HTML, the urls should be quoted. Then" _ , "the regex should find ""http://ads.domain.ext"" but not ""http://sad.domain.ext""." _ , "Add more samples like <a href=""http://ads.domain.ext/index.html?a=b&c=d"" whatever>," _ , "or ""https://ads.domain.ext"" or ""http://adsx.domain.ext"" to see whether and where" _ , "more tinkering with the pattern is needed." _ ), vbCrLf ) WScript.Echo sTest Dim reUrl : Set reUrl = New RegExp reUrl.Global = True reUrl.IgnoreCase = True reUrl.Pattern = """(http://ads\.[^""]+)""" Dim oMTS : Set oMTS = reUrl.Execute( sTest ) Dim oMT For Each oMT In oMTS WScript.Echo oMT.SubMatches( 0 ) Next output: === findUrls: find urls using regexp ========================================== Assuming your data is like HTML, the urls should be quoted. Then the regex should find "http://ads.domain.ext" but not "http://sad.domain.ext". Add more samples like <a href="http://ads.domain.ext/index.html?a=b&c=d" whatever>, or "https://ads.domain.ext" or "http://adsx.domain.ext" to see whether and where more tinkering with the pattern is needed. http://ads.domain.ext http://ads.domain.ext/index.html?a=b&c=d === findUrls: 0 done (00:00:00) =============================================== |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Regular Expression help C# | .NET General | |||
| Regular Expression Question | PowerShell | |||
| Help with a regular expression | VB Script | |||
| Simple Regular Expression | PowerShell | |||
| simple regular expression | PowerShell | |||