Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
ASP regular expressions help
Old 03-15-2005, 08:12 PM ASP regular expressions help
kline11's Avatar
SearchBliss Web Tools

Posts: 1,726
Name: John
Location: USA
Trades: 0
I'm developing a new tool (keyword analysis) that uses regular expression patterns to query or spider pieces of web pages. I works just fine with title tags and meta tags, but the problem, for instance, is querying code that ends with ">, like alt tags.

I tried : regExp.Pattern = "alt=""(.*)?"""

But this only worked if the alt text ended with ">, but when there is more like:

...alt="text text text" style="padding-top:2px;">

I would get:

...text text text" style="padding-top:2px;

I only want the alt text. I also tried:
regExp.Pattern = "\balt=""(.*)?""\b"

This gave the same result, just without the "padding-top:2px;

Why won't the pattern stop after the second quotation mark?

If anyone can help, I would really appreciate it. I've read alot on the web about regular expressions but nothing helped. Thanks!
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
kline11 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-16-2005, 05:35 AM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
I know no ASP, but if the regEx syntax is the same as PHP and Perl, then you might try this:
Also I'm guessing that "" is the escape sequence for " in ASP?

regExp.Pattern = "alt=""([^""]*)?"""

[^xyz] matches any single character except x, y or z, so [^"]* matches any string with no " in it.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 03-16-2005, 10:48 AM
kline11's Avatar
SearchBliss Web Tools

Posts: 1,726
Name: John
Location: USA
Trades: 0
Oberon, thanks. I will test this some time today and let you know if it works out. Again, thanks.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
kline11 is offline
Reply With Quote
View Public Profile
 
Old 03-16-2005, 11:36 AM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
Glad I could help. I'm not entirely certain how ASP handles quote marks within quoted strings, so you may have to adjust it slightly. In PHP I would write:
'#alt="([^"]*)?"#'
Using single quotes on the outside so the double ones are taken literally and don't need escaping. # is the pattern delimiter, but it seems ASP doesn't require these.
If anyone knows more about escape sequences in ASP, feel free to correct me on any of this.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 03-16-2005, 11:51 AM
Minaki's Avatar
Defies a Status

Posts: 1,626
Location: Guildford, UK
Trades: 0
You were right the first time, top put a double quote inside a string, escape it using 2 double quotes. Or concatanate it like this
StringX = StringY & Chr(34) & StringZ
__________________
Minaki Serinde MCP
"Wow, Linux is nearly on-par with Windows ME!"

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Minaki is offline
Reply With Quote
View Public Profile Visit Minaki's homepage!
 
Old 03-16-2005, 03:43 PM
kline11's Avatar
SearchBliss Web Tools

Posts: 1,726
Name: John
Location: USA
Trades: 0
Oberon, thank you, thank you, thank you!
This one regExp.Pattern = "alt=""([^""]*)?"""
worked perfectly! I was racking my brains for four hours and I'd be doing this again today if it wasn't for you. I truely appreciate it.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
kline11 is offline
Reply With Quote
View Public Profile
 
Old 03-16-2005, 05:17 PM
kline11's Avatar
SearchBliss Web Tools

Posts: 1,726
Name: John
Location: USA
Trades: 0
Oberon. You seem to have a great understanding of regular expressions. I hate to be a bother. I just have one more regular expression question. Is there any way to expand the "alt=""([^""]*)?""" to query every alt tag on the page and ignore everything inbetween them?

Thanks again for your help.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
kline11 is offline
Reply With Quote
View Public Profile
 
Old 03-16-2005, 08:05 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
For that sort of effect I would reach for something like PHP's preg_match_all() which returns an array of strings that match. Does ASP have a similar thing?
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 03-16-2005, 08:37 PM
kline11's Avatar
SearchBliss Web Tools

Posts: 1,726
Name: John
Location: USA
Trades: 0
I don't know. I've written a good amount of asp and have never come accross anything similar, but there must be. I would find it hard to believe that asp is that limited. I guess there is no quick fix using the regular expression pattern. I'll try searching for preg_match_all() in relation to asp. Thanks again.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
kline11 is offline
Reply With Quote
View Public Profile
 
Old 03-17-2005, 07:08 PM
kline11's Avatar
SearchBliss Web Tools

Posts: 1,726
Name: John
Location: USA
Trades: 0
Oberon, thanks again for all of your help. I was able to find an ASP alternative preg_match_all() using the For/Next loop

For each match in matches
<statement>
Next

This worked like a charm. Now the rest of the work should be pretty standard.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
kline11 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to ASP regular expressions help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.56197 seconds with 12 queries