Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - regular expression help

Reply
 
Old 08-02-2008   #1 (permalink)
Stimp


 
 

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 SpecsSystem Spec
Old 08-02-2008   #2 (permalink)
Evertjan.


 
 

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 SpecsSystem Spec
Old 08-02-2008   #3 (permalink)
Stimp


 
 

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
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.

cheers.
--

fiddlewidawiddum
My System SpecsSystem Spec
Old 08-02-2008   #4 (permalink)
Al Dunbar


 
 

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!
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"

/Al


My System SpecsSystem Spec
Old 08-02-2008   #5 (permalink)
Evertjan.


 
 

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.
Already shown in the other group,
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 SpecsSystem Spec
Old 08-02-2008   #6 (permalink)
Al Dunbar


 
 

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.
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.

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 SpecsSystem Spec
Old 08-02-2008   #7 (permalink)
Stimp


 
 

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 SpecsSystem Spec
Old 08-02-2008   #8 (permalink)
Stimp


 
 

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.
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

--

fiddlewidawiddum
My System SpecsSystem Spec
Old 08-02-2008   #9 (permalink)
Evertjan.


 
 

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
Ever heard of the word "sorry" if you make a mistake?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
My System SpecsSystem Spec
Old 08-02-2008   #10 (permalink)
Stimp


 
 

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?
I will if you apologise for cross-posting the same reply twice

--

fiddlewidawiddum
My System SpecsSystem Spec
Reply

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


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46