![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | regular expression help Hi all, given a string: " <img class='myclass' alt='my picture' src='image.jpg' /> " (where alt and src are changeable) how do I create the following string: " <div class='container'> <div class='inner'> <img class='myclass' alt='my picture' src='image.jpg' /> <p>my picture</p> </div> </div> " (where the contents of <p></p> are the same as the image 'alt') ? I believe a regular expression would solve this but I'm not sure on the syntax. something like: regex.replace("<img class='myclass' alt='$1' src='$2' />","<div class='container'><div class='inner'><img class='myclass' alt='$1' src='$2' /><p>$1</p></div></div>") Any ideas? Thanks! -- fiddlewidawiddum |
My System Specs![]() |
| | #2 (permalink) |
| | Re: regular expression help Stimp wrote on 02 aug 2008 in microsoft.public.scripting.vbscript: Quote: > Hi all, > > given a string: > > " <img class='myclass' alt='my picture' src='image.jpg' /> " > > (where alt and src are changeable) > > how do I create the following string: > > " <div class='container'> > <div class='inner'> > <img class='myclass' alt='my picture' src='image.jpg' /> > <p>my picture</p> > </div> > </div> " > > (where the contents of <p></p> are the same as the image 'alt') ? > > > I believe a regular expression would solve this but I'm not sure on the > syntax. > > something like: > > regex.replace("<img class='myclass' alt='$1' src='$2' />","<div > class='container'><div class='inner'><img class='myclass' alt='$1' > src='$2' /><p>$1</p></div></div>") > > > Any ideas? Thanks! Please do not multipost -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress) |
My System Specs![]() |
| | #3 (permalink) |
| | Re: regular expression help On Sat, 2 Aug 2008 Evertjan. <exjxw.hannivoort@xxxxxx> wrote: Quote: > Stimp wrote on 02 aug 2008 in microsoft.public.scripting.vbscript: > Quote: >> Hi all, >> >> given a string: >> >> " <img class='myclass' alt='my picture' src='image.jpg' /> " >> >> (where alt and src are changeable) >> >> how do I create the following string: >> >> " <div class='container'> >> <div class='inner'> >> <img class='myclass' alt='my picture' src='image.jpg' /> >> <p>my picture</p> >> </div> >> </div> " >> >> (where the contents of <p></p> are the same as the image 'alt') ? >> >> >> I believe a regular expression would solve this but I'm not sure on the >> syntax. >> >> something like: >> >> regex.replace("<img class='myclass' alt='$1' src='$2' />","<div >> class='container'><div class='inner'><img class='myclass' alt='$1' >> src='$2' /><p>$1</p></div></div>") >> >> >> Any ideas? Thanks! > > Please do not multipost have posted to since many people don't read both groups. Answers in other groups will be placed here. cheers. -- fiddlewidawiddum |
My System Specs![]() |
| | #4 (permalink) |
| | Re: regular expression help "Stimp" <ren@xxxxxx> wrote in message news:slrng9991n.nnj.ren@xxxxxx Quote: > Hi all, > > given a string: > > " <img class='myclass' alt='my picture' src='image.jpg' /> " > > (where alt and src are changeable) > > how do I create the following string: > > " <div class='container'> > <div class='inner'> > <img class='myclass' alt='my picture' src='image.jpg' /> > <p>my picture</p> > </div> > </div> " > > (where the contents of <p></p> are the same as the image 'alt') ? > > > I believe a regular expression would solve this but I'm not sure on the > syntax. > > something like: > > regex.replace("<img class='myclass' alt='$1' src='$2' />","<div > class='container'><div class='inner'><img class='myclass' alt='$1' > src='$2' /><p>$1</p></div></div>") > > > Any ideas? Thanks! expressions. Here's how I would solve this one: input = "<img class='myclass' alt='my picture' src='image.jpg' />" alt = split(split(input,"alt='")(1),"'")(0) output = "<div class='container'>" _ & vbnewline & "<div class='inner'>" _ & vbnewline & input _ & vbnewline & "<p>" & alt & "</p>" & suffix & vbnewline & "</div" _ & vbnewline & "</div" /Al |
My System Specs![]() |
| | #5 (permalink) |
| | Re: regular expression help Stimp wrote on 02 aug 2008 in microsoft.public.scripting.vbscript: Quote: Quote: Quote: >>> Any ideas? Thanks! >> >> Please do not multipost > as I mentioned in .javascript .. this is a post relevant to the groups I > have posted to since many people don't read both groups. > > Answers in other groups will be placed here. and this shows you are wrong not to heed Netiquette. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress) |
My System Specs![]() |
| | #6 (permalink) |
| | Re: regular expression help "Stimp" <ren@xxxxxx> wrote in message news:slrng99auc.nnj.ren@xxxxxx Quote: > On Sat, 2 Aug 2008 Evertjan. <exjxw.hannivoort@xxxxxx> wrote: Quote: >> Stimp wrote on 02 aug 2008 in microsoft.public.scripting.vbscript: >> Quote: >>> Hi all, >>> >>> given a string: >>> >>> " <img class='myclass' alt='my picture' src='image.jpg' /> " >>> >>> (where alt and src are changeable) >>> >>> how do I create the following string: >>> >>> " <div class='container'> >>> <div class='inner'> >>> <img class='myclass' alt='my picture' src='image.jpg' /> >>> <p>my picture</p> >>> </div> >>> </div> " >>> >>> (where the contents of <p></p> are the same as the image 'alt') ? >>> >>> >>> I believe a regular expression would solve this but I'm not sure on the >>> syntax. >>> >>> something like: >>> >>> regex.replace("<img class='myclass' alt='$1' src='$2' />","<div >>> class='container'><div class='inner'><img class='myclass' alt='$1' >>> src='$2' /><p>$1</p></div></div>") >>> >>> >>> Any ideas? Thanks! >> >> Please do not multipost > as I mentioned in .javascript .. this is a post relevant to the groups I > have posted to since many people don't read both groups. > > Answers in other groups will be placed here. to a small number of groups, the best way to handle it is to CROSSPOST rather than MULTIPOST. That way a reply in one group will be sent to all groups without you having to, redundantly and manually copy from one group to the other to try to keep them in synch. FYI, the reason that many of us find multiposting frustrating is that we often see one of the posts with no responses, and then spend a fair amount of time supplying an answer - only to find out that was a waste of time because someone already supplied the answer in another group. /Al |
My System Specs![]() |
| | #7 (permalink) |
| | Re: regular expression help On Sat, 2 Aug 2008 Al Dunbar <AlanDrub@xxxxxx> wrote: Quote: > > "Stimp" <ren@xxxxxx> wrote in message > news:slrng9991n.nnj.ren@xxxxxx Quote: >> Hi all, >> >> given a string: >> >> " <img class='myclass' alt='my picture' src='image.jpg' /> " >> >> (where alt and src are changeable) >> >> how do I create the following string: >> >> " <div class='container'> >> <div class='inner'> >> <img class='myclass' alt='my picture' src='image.jpg' /> >> <p>my picture</p> >> </div> >> </div> " >> >> (where the contents of <p></p> are the same as the image 'alt') ? >> >> >> I believe a regular expression would solve this but I'm not sure on the >> syntax. >> >> something like: >> >> regex.replace("<img class='myclass' alt='$1' src='$2' />","<div >> class='container'><div class='inner'><img class='myclass' alt='$1' >> src='$2' /><p>$1</p></div></div>") >> >> >> Any ideas? Thanks! > I must be an irregular kind of guy, as I have never gotten into regular > expressions. Here's how I would solve this one: > > input = "<img class='myclass' alt='my picture' src='image.jpg' />" > alt = split(split(input,"alt='")(1),"'")(0) > output = "<div class='container'>" _ > & vbnewline & "<div class='inner'>" _ > & vbnewline & input _ > & vbnewline & "<p>" & alt & "</p>" & suffix > & vbnewline & "</div" _ > & vbnewline & "</div" I managed to get an answer to this.. thanks for the input though regex.replace( @"\<img\sclass\='myclass'\salt\='(.*?)'\ssrc\='(.*?)'\s\/\>", @"<div class='container'><div class='inner'><img class='myclass' alt='$1' src='$2' /><p>$1</p></div></div>"); -- fiddlewidawiddum |
My System Specs![]() |
| | #8 (permalink) |
| | Re: regular expression help On Sat, 2 Aug 2008 Al Dunbar <AlanDrub@xxxxxx> wrote: Quote: > > Evertjan's comment is still valid. When you have a thread that has relevence > to a small number of groups, the best way to handle it is to CROSSPOST > rather than MULTIPOST. That way a reply in one group will be sent to all > groups without you having to, redundantly and manually copy from one group > to the other to try to keep them in synch. the groups .. which would seem counter to good "netiquette" as Evertjan likes to harp on about. Cheers for the constructive response ![]() -- fiddlewidawiddum |
My System Specs![]() |
| | #9 (permalink) |
| | Re: regular expression help Stimp wrote on 02 aug 2008 in microsoft.public.scripting.vbscript: Quote: > On Sat, 2 Aug 2008 Al Dunbar <AlanDrub@xxxxxx> wrote: Quote: >> >> Evertjan's comment is still valid. When you have a thread that has >> relevence to a small number of groups, the best way to handle it is >> to CROSSPOST rather than MULTIPOST. That way a reply in one group >> will be sent to all groups without you having to, redundantly and >> manually copy from one group to the other to try to keep them in >> synch. > ah ok, I was under the impression that the replies went to only one of > the groups .. which would seem counter to good "netiquette" as > Evertjan likes to harp on about. > > Cheers for the constructive response ![]() -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress) |
My System Specs![]() |
| | #10 (permalink) |
| | Re: regular expression help On Sat, 2 Aug 2008 Evertjan. <exjxw.hannivoort@xxxxxx> wrote: Quote: > Stimp wrote on 02 aug 2008 in microsoft.public.scripting.vbscript: > Quote: >> On Sat, 2 Aug 2008 Al Dunbar <AlanDrub@xxxxxx> wrote: Quote: >>> >>> Evertjan's comment is still valid. When you have a thread that has >>> relevence to a small number of groups, the best way to handle it is >>> to CROSSPOST rather than MULTIPOST. That way a reply in one group >>> will be sent to all groups without you having to, redundantly and >>> manually copy from one group to the other to try to keep them in >>> synch. >> ah ok, I was under the impression that the replies went to only one of >> the groups .. which would seem counter to good "netiquette" as >> Evertjan likes to harp on about. >> >> Cheers for the constructive response ![]() > Ever heard of the word "sorry" if you make a mistake? ![]() -- fiddlewidawiddum |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Regular Expression help C# | .NET General | |||
| regular expression capture | PowerShell | |||
| Regular Expression for ../ | .NET General | |||
| Help with a regular expression | VB Script | |||
| simple regular expression | PowerShell | |||