.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

RegEx Request - Extract an tag from string...

Posted By:      Posted Date: August 28, 2010    Points: 0   Category :.NET Framework
Hello, Can anyone give me a regular expression that will extract the <img> tag from a string.  I am receiving descriptions from an rss feed and the description contains an <img> tag in the text.  I want to extract the <img> so that I can display it in a different location on my page. I have fooled with some regular expressions, but my knowledge of them is not very good. Thanks in advance for any help!!

View Complete Post

More Related Resource Links

Extract String using RegEx

HelloI have below data in string format in a field in table and would like to parse the name from the quantity. The name should be anything before it hits a numeric numberin below example CHLORPHENIRAMINE is the name. i really appreciate if i can get a regex to extract the name from below string                                    "CHLORPHENIRAMINE 8MG CAP SA",                                    "CHLORPHENIRAMINE 12MG CP SA",                                     "CHLORPHENIRAMINE 4MG TABLET",                                     "CLEMASTINE FUM 2.68MG TAB",             &n

extract picture data from a string


dears,advance thanks.can anybdy help to solve my problem which is describing below.

Example- %%D1,100,0,0004[data...][0d0a]

Head - %%D1
Amount of data package -100
The data package No. - 0
Data Length -1024 (0004 (low bit in front, high bit in back) 0004= 0x0400=1024;)

data- Original Picture data -1024(maximum)
Tail -0x0d0a
Data in hex

from the above example i want to extract picture data and need to store in to the sql table.sql table columname is image and datatype is also image.after that i wanted to display this image column to an aspx page.

expecting help asap.

Split string using Regex with escape sequences

What is the regex to split a string using the delimiter ';', but not split on '\;' ? Backslash would be my escape character in my split string, so finding '\;' would not split, but '\\;' would split. For example I want a regex that would split the following:     "aaa;bb;cccc\;dd\;eee\\;ff\\;ggg\\\;hhh" into the following string array:     aaa     bb     ccc\;dd\;eee\\     ff\\     ggg\\\;hhh   Thanks!   -Sylvain

How to extract City State Zip using Regex match

Hi there - I am parsing a file which contains customer address in the following 2 formats:   Format #1 12345 Melrose Place New York NY USA 12987     Format # 2: 12345 Melrose Place New York NY 12987   I need to put the data into Address, City, State and Zip fields. I am able to parse and put the data (specifically line 2) in the fields for format #1 but am having issues doing the same for format # 2 because format # 2 doesn't have USA as a reference point. Below is my code if any expert can help that will be appreciated Dim AddressChunk As String = tokenizer.NextToken() If AddressChunk.Contains("USA") Then _State = AddressChunk.Substring(AddressChunk.IndexOf("USA") - 4, 2).Trim _City = AddressChunk.Substring(0, AddressChunk.IndexOf("USA") - 4).Trim _Zip = Regex.Match(AddressChunk, "\d{5}").Value Else _Zip = Regex.Match(AddressChunk, "\d{5}").Value _State = AddressChunk.Substring(Regex.Match(AddressChunk, "\s[a-zA-Z]{2}\s\d{5}").Value - 5).Trim _City = End If

RegEx Request : Get all the tag in a webpage.

Hi! I have used Regular Expression(?<=img\s+src\=[\x27\x22])(?<Url>[^\x27\x22]*)(?=[\x27\x22]) to get about content of src tag.  For this case:    - Example: <img src="/vasep/Data/Sites/1/picture002.jpg" alt="hhhh" title="hhhhh" width="550" height="412" />        Regular Expression is true. I get content of src tag. But!! For this case:  -  Exmple: <img title="hhhhh" src="/vasep/Data/Sites/1/picture002.jpg" alt="hhhh"  width="550" height="412" />      Regular Expression is false. I do not get content of src tag.Please help me!

Obtain url query string during Json request

So I'm writing an MVC application, and have a JsonResult post back to obtain some item information for scanned items on a warehouse application I am writing. I'm trying to obtain a URL query string value though, and cannot seem to obtain one via the normal 'Request.QueryString['variable']' way... Is there a way to do this? I also thought about just passing the parameter into my post, but I already have a single value on my jquery post, and I am unsure if I can tack on more values to this. Thanks for your help.

extract date from text string - Transact-SQL

Hello, I have a field in my database with an archived date... (Giampaoli  Live Oak, Almonds Archive 09/16/10) I need to be able to extract the date from this, then perform a datepart function on it... How do I extract the date into it's own value using just SQL? Thanks, Wes

String encryption problem with request.querystring (urlencode/decode)


I need to pass a userid as a guid number through a url quesrystring

 my starting GUID is in string format =  "23c6e6a5-e9fc-4fd0-aa15-e5db9b900388"

1) I encrypt it using tripledes

the resulting string value =  "nJYKpGwOeoOWepKPSDyNnO+xk+ZcfYZnyxvAnKTNCMV/ZJ7CfDKcmA=="

if I immeadiately decrypt it get the expected original value (so my tripledes provider is working)

2) I then urlencode the value for placing into the url which results in:

urlencoded = "nJYKpGwOeoOWepKPSDyNnO%2bxk%2bZcfYZnyxvAnKTNCMV%2fZJ7CfDKcmA%3d%3d"

3) when a read it back from the url using Request.QueryString (a function which automatically decodes the value)

I get the value: "nJYKpGwOeoOWepKPSDyNnO xk ZcfYZnyxvAnKTNCMV/ZJ7CfDKcmA=="

It appears the "+" characters where replaced with " "

This incorrect value caused the tripledes decryption to fail.
I am using VS 2010 Framework 4.0, IIS7, IE8 and the System.Security.Cryptography.TripleDESCryptoServiceProvider

Is this a bug or am I doing something wrong. It appears the the problem is with the urlencode or the embeded urldecode which is part of request.querystring

Many thanks for any assistance in how to resolve this.


Simple ASP.NET SOAP request to return string



I have a requirement to build a simple ASP.NET web page which sends some parameters to a web service, and then displays the string which was returned.

I'm a complete .NET newby and the only examples I can find seem really really complex.  I just need something mega simple, but which an handle parameters being sent to the web service.  Can anyone point me in the direction of a simple bit of C# which will do this with no frills or fuss?

Any help much appreciated, thanks!

Extract number from string


How i extract 0 from " flag=0" OR "flag = 0".

These are string value.

Having trouble creating RegEx to extract value from GridView row

Hey Everyone,
Since I had such great help with my first RegEx problem I thought I'd give it a second try. This one is a fair bit more complicated. I need to extract a value from within an onclick attribute of an input (button) in a the row of a grid that contains a column that contains certain text. Here is the html: 

<tr class="rgRow" id="ctl00_ContentPlaceHolder1_OrganizationsRadGrid_ctl00__24">

Replace space from string - REGEX.



I have some problem with RegEx.

I have text:

"something here [tagQuote=Name of Author]bla bla bla[/tagQuote] something here"

And now I want to replace all the whitespace character in quote attribute with "%#%#%#%".

So I want to have: [tagQuote=Name%#%#%#%of%#%#%#%Author]bla bla bla[/tagQuote]

So remove all of the whitespaces between "[tagQuote=" and "]...[/tagQuote]"

Extract String based on commas


Is there a simple way in a select query to obtain only part of a string counting from commas?

For example, I have a string with the following value:


The part I am interested is just OU=Lambert


The part of the string I want is always after the third comma from the right:

                                                  3                  2            1

And I don't actually need the OU= either if that helps.

Thank you in advance.

Allan Browning

RegEx Request : Get all the tag in a webpage.


How do I get all the <img src=" "> tags on a web page. Includes the value of the src. I need to in my C# application. I want to grab a webpage and parse the page to get only all the <img src=""> tags and put it in an array or in a database. I want to check the <img src='"> tag of two pages and check if they are similar or not. If not, error or prompt will occur.  

Please help.

Thanks and more power.

Does Regular Expression (RegEx) able to extract Sentence from paragraphs



I am new to Regular languages; I have been trying to find out whether Regex is able to extract sentences from any paragraph (text) on PDF format based on particular words (pattern).



Can you please outlines this with example in C#


Thank you in advance  

Regex solution to ID Excel Cell references in an Excel Formula string


Is there a RegEex solution to accomplish the following:

- Assuming Operator Pattern is "[/*^&()=<>,+-]"
- Cell References are pre-fixed Post-fixed by an Operator (including a comma)
- Cell References Start with Alpha Characters without-interruption - by an operator
    then Followed by numerics-without-interruption - by an operator

----------------------FORMULA STRING INPUT----------------| |---OUTPUT---|
                                                                                        Cell    Cell
1) =I82*I83/365*0.11      <  <  <  <  <  <  <  <  <  <  <  < >  I82     I83
2) =IF(H84>H80*0.91,H84,0.91*H80) <  <  <  <  <  <  <  < >&nbs

HTTP POST request and encoded string



I have to do a simple HTTP POST request by key/value pairs and receive a XML file with a session key. I made it work, but there's something strange about it - when session key includes character '&', then it return encoded like '&amp;'. After that my application needs to send that session key to server every time I make a query. When session key includes '&', then query won't work, because server side is expecting correct (not encoded) session key. Does somebody knows how to fix this problem? My HTTP POST Content-type is "application/x-www-form-urlencoded".

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend