Regex r = new Regex(@"<.*?td.*?width.*?=.*?100.*?valign.*?=.*?top.*?>.*?<.*?td.*?valign=.*?top.*?>.*?<.*?a.*?>.*?(<.*?img.*?src.*?=.*?""(\/upload.*?)"".*?>)*?.*?<.*?\/.*?a.*?>.*?<.?a.*?>(.*?)<.*?\/.*?a.*?>.*?<.*?br.*?>.*?<.*?br.*?>(.*?)<.*?span.*?class.*?=.*?catalog-price.*?>(.*?)<.*?\/.*?span.*?>.*?<.*?\/.*?td.*?>",
RegexOptions.IgnoreCase);
I am need that regexp work correct if image is absent in text (image may be present or no). Now it did not work properly. Where is my mistake? Help me, please.
Hi, Regular expressions are a good way to validate text fields such as names, addresses, phone numbers, and other user information. To check whether there is image on the page, it is better to use jQuery, for example, you can add the following codes to your
markup. If there is any image, you will receive an alert “image exists”, else, “No image”.
alexfreeman
Member
1 Points
23 Posts
Need help with regular expression
May 27, 2012 09:50 PM|LINK
Hi, guys. I have a regexp.
Regex r = new Regex(@"<.*?td.*?width.*?=.*?100.*?valign.*?=.*?top.*?>.*?<.*?td.*?valign=.*?top.*?>.*?<.*?a.*?>.*?(<.*?img.*?src.*?=.*?""(\/upload.*?)"".*?>)*?.*?<.*?\/.*?a.*?>.*?<.?a.*?>(.*?)<.*?\/.*?a.*?>.*?<.*?br.*?>.*?<.*?br.*?>(.*?)<.*?span.*?class.*?=.*?catalog-price.*?>(.*?)<.*?\/.*?span.*?>.*?<.*?\/.*?td.*?>", RegexOptions.IgnoreCase);
I am need that regexp work correct if image is absent in text (image may be present or no). Now it did not work properly. Where is my mistake? Help me, please.
Allen Li - M...
Star
10411 Points
1196 Posts
Re: Need help with regular expression
May 29, 2012 05:01 AM|LINK
Hi, Regular expressions are a good way to validate text fields such as names, addresses, phone numbers, and other user information. To check whether there is image on the page, it is better to use jQuery, for example, you can add the following codes to your markup. If there is any image, you will receive an alert “image exists”, else, “No image”.
<script src="http://code.jquery.com/jquery-latest.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { var images = $("img"); if (images.length > 0) { alert("image exists"); } else { alert("No image"); } }); </script>If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework