Hi,

Is there a straight forward way to extract the information within
quotes only. There could be differnet types of values within quotes
and so is there a way to extract these.

Thanks ,
Sa

..TopCell "CAP_SMD_2512_.250X.130B_.043HT"

Re: extracting the info from quotes!! by Evertjan

Evertjan
Fri May 09 14:54:24 CDT 2008

karsagarwal@gmail.com wrote on 09 mei 2008 in
microsoft.public.scripting.vbscript:

> Is there a straight forward way to extract the information within
> quotes only. There could be differnet types of values within quotes
> and so is there a way to extract these.
>
> ..TopCell "CAP_SMD_2512_.250X.130B_.043HT"


Not a straight forward way, but there is a straightforward way.

This is about strings, I suppose, not about values:


s = "..TopCell ""CAP_SMD_2512_.250X.130B_.043HT"", blah"
n = instr(s,"""")
s = mid(s,n+1)
n = instr(s,"""")
s = left(s,n-1)

or use Regular Expressions



--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Re: extracting the info from quotes!! by Pegasus

Pegasus
Fri May 09 16:10:41 CDT 2008


<karsagarwal@gmail.com> wrote in message
news:7d97bb14-d8a1-40c3-9582-41b33005a267@t12g2000prg.googlegroups.com...
> Hi,
>
> Is there a straight forward way to extract the information within
> quotes only. There could be differnet types of values within quotes
> and so is there a way to extract these.
>
> Thanks ,
> Sa
>
> ..TopCell "CAP_SMD_2512_.250X.130B_.043HT"

Here is another "straighforward" way:
s = "..TopCell ""CAP_SMD_2512_.250X.130B_.043HT"""
aStrings = Split(s, """")
WScript.Echo aStrings(1)

BTW, when asking such questions it is better to formulate them
precisely by asking "how can I ..." instead of "Is there a way?".
Someone might answer literally and say "yes, there is a way" . . .



Re: extracting the info from quotes!! by karsagarwal

karsagarwal
Fri May 09 16:45:01 CDT 2008

On May 9, 2:10=A0pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
> <karsagar...@gmail.com> wrote in message
>
> news:7d97bb14-d8a1-40c3-9582-41b33005a267@t12g2000prg.googlegroups.com...
>
> > Hi,
>
> > Is there a straight forward way to extract the information within
> > quotes only. There could be differnet types of values within quotes
> > and so is there a way to extract these.
>
> > Thanks ,
> > Sa
>
> > ..TopCell "CAP_SMD_2512_.250X.130B_.043HT"
>
> Here is another "straighforward" way:
> s =3D "..TopCell ""CAP_SMD_2512_.250X.130B_.043HT"""
> aStrings =3D Split(s, """")
> WScript.Echo aStrings(1)
>
> BTW, when asking such questions it is better to formulate them
> precisely by asking "how can I ..." instead of "Is there a way?".
> Someone might answer literally and say "yes, there is a way" . . .


I like your approach. Its as straightforard as you can get. But I
get an error.

My file contains:
=2ENumber "1000-234234-35435"

part of the code:
const Delim=3D """"
Do Until objFileR.AtEndofStream
if (RegExpTest(".Number", rawline)) Then
aStrings=3Dsplit(rawline,Delim)
WScript.Echo aStrings(1)
end if
Loop

Any inputs would be appreciated.

Thanks,
SA


Re: extracting the info from quotes!! by Pegasus

Pegasus
Fri May 09 16:56:41 CDT 2008


<karsagarwal@gmail.com> wrote in message
news:782606fe-a06c-4309-a0e2-cea38930550c@u12g2000prd.googlegroups.com...
On May 9, 2:10 pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
> <karsagar...@gmail.com> wrote in message
>
> news:7d97bb14-d8a1-40c3-9582-41b33005a267@t12g2000prg.googlegroups.com...
>
> > Hi,
>
> > Is there a straight forward way to extract the information within
> > quotes only. There could be differnet types of values within quotes
> > and so is there a way to extract these.
>
> > Thanks ,
> > Sa
>
> > ..TopCell "CAP_SMD_2512_.250X.130B_.043HT"
>
> Here is another "straighforward" way:
> s = "..TopCell ""CAP_SMD_2512_.250X.130B_.043HT"""
> aStrings = Split(s, """")
> WScript.Echo aStrings(1)
>
> BTW, when asking such questions it is better to formulate them
> precisely by asking "how can I ..." instead of "Is there a way?".
> Someone might answer literally and say "yes, there is a way" . . .


I like your approach. Its as straightforard as you can get. But I
get an error.

My file contains:
.Number "1000-234234-35435"

part of the code:
const Delim= """"
Do Until objFileR.AtEndofStream
if (RegExpTest(".Number", rawline)) Then
aStrings=split(rawline,Delim)
WScript.Echo aStrings(1)
end if
Loop

Any inputs would be appreciated.

Thanks,
SA

=======================

Why use a regular expression when instr() would do?

if instr(uCase(rawline), ".NUMBER") > 0 Then
aStrings=split(rawline,Delim)
WScript.Echo aStrings(1)
end if
Loop

It's a little difficult to tell you what your problem might
be while you're concealing the error message from us.
Maybe the array aStrings has fewer than two elements,
so a check of uBound(aStrings) would be required.



Re: extracting the info from quotes!! by James

James
Fri May 09 16:59:15 CDT 2008

"Evertjan." <exjxw.hannivoort@interxnl.net> wrote in message
news:Xns9A99DED7DBE3eejj99@194.109.133.242...
> karsagarwal@gmail.com wrote on 09 mei 2008 in
> microsoft.public.scripting.vbscript:
>
>> Is there a straight forward way to extract the information within
>> quotes only. There could be differnet types of values within quotes
>> and so is there a way to extract these.
>>
>> ..TopCell "CAP_SMD_2512_.250X.130B_.043HT"
>
>
> Not a straight forward way, but there is a straightforward way.
>
> This is about strings, I suppose, not about values:
>
>
> s = "..TopCell ""CAP_SMD_2512_.250X.130B_.043HT"", blah"
> n = instr(s,"""")
> s = mid(s,n+1)
> n = instr(s,"""")
> s = left(s,n-1)
>
> or use Regular Expressions

If you wish to use a regular expression instead of the string
manipulation, something like this should work:

s = "..TopCell ""CAP_SMD_2512_.250X.130B_.043HT"", blah"

Set oRegEx = CreateObject("VBScript.RegExp")
oRegEx.Pattern = """([^""]*?)"""
s = oRegEx.Replace(s, "$1")



Re: extracting the info from quotes!! by karsagarwal

karsagarwal
Fri May 09 17:49:50 CDT 2008

On May 9, 2:56=A0pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
> <karsagar...@gmail.com> wrote in message
>
> news:782606fe-a06c-4309-a0e2-cea38930550c@u12g2000prd.googlegroups.com...
> On May 9, 2:10 pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
>
>
>
>
>
> > <karsagar...@gmail.com> wrote in message
>
> >news:7d97bb14-d8a1-40c3-9582-41b33005a267@t12g2000prg.googlegroups.com...=

>
> > > Hi,
>
> > > Is there a straight forward way to extract the information within
> > > quotes only. There could be differnet types of values within quotes
> > > and so is there a way to extract these.
>
> > > Thanks ,
> > > Sa
>
> > > ..TopCell "CAP_SMD_2512_.250X.130B_.043HT"
>
> > Here is another "straighforward" way:
> > s =3D "..TopCell ""CAP_SMD_2512_.250X.130B_.043HT"""
> > aStrings =3D Split(s, """")
> > WScript.Echo aStrings(1)
>
> > BTW, when asking such questions it is better to formulate them
> > precisely by asking "how can I ..." instead of "Is there a way?".
> > Someone might answer literally and say "yes, there is a way" . . .
>
> I like your approach. Its as straightforard =A0as you can get. =A0But I
> get an error.
>
> My file contains:
> .Number "1000-234234-35435"
>
> part of the code:
> const Delim=3D """"
> Do Until objFileR.AtEndofStream
> if (RegExpTest(".Number", rawline)) Then
> aStrings=3Dsplit(rawline,Delim)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 WScript.Ec=
ho aStrings(1)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 end if
> Loop
>
> Any inputs would be appreciated.
>
> Thanks,
> SA
>
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>
> Why use a regular expression when instr() would do?
>
> if instr(uCase(rawline), ".NUMBER") > 0 Then
> =A0 =A0 aStrings=3Dsplit(rawline,Delim)
> =A0 =A0 WScript.Echo aStrings(1)
> end if
> Loop
>
> It's a little difficult to tell you what your problem might
> be while you're concealing the error message from us.
> Maybe the array aStrings has fewer than two elements,
> so a check of uBound(aStrings) would be required.- Hide quoted text -
>
> - Show quoted text -

Yes it works. Thank you very much. So how do i get the string without
the quotes. I want the bare string for further mainpulation.

Thanks,
Sa

Re: extracting the info from quotes!! by Pegasus

Pegasus
Fri May 09 17:58:17 CDT 2008


<karsagarwal@gmail.com> wrote in message
news:186b02c3-b8e0-46ff-883d-75e78895e449@y22g2000prd.googlegroups.com...
On May 9, 2:56 pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
> <karsagar...@gmail.com> wrote in message
>
> news:782606fe-a06c-4309-a0e2-cea38930550c@u12g2000prd.googlegroups.com...
> On May 9, 2:10 pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
>
>
>
>
>
> > <karsagar...@gmail.com> wrote in message
>
> >news:7d97bb14-d8a1-40c3-9582-41b33005a267@t12g2000prg.googlegroups.com...
>
> > > Hi,
>
> > > Is there a straight forward way to extract the information within
> > > quotes only. There could be differnet types of values within quotes
> > > and so is there a way to extract these.
>
> > > Thanks ,
> > > Sa
>
> > > ..TopCell "CAP_SMD_2512_.250X.130B_.043HT"
>
> > Here is another "straighforward" way:
> > s = "..TopCell ""CAP_SMD_2512_.250X.130B_.043HT"""
> > aStrings = Split(s, """")
> > WScript.Echo aStrings(1)
>
> > BTW, when asking such questions it is better to formulate them
> > precisely by asking "how can I ..." instead of "Is there a way?".
> > Someone might answer literally and say "yes, there is a way" . . .
>
> I like your approach. Its as straightforard as you can get. But I
> get an error.
>
> My file contains:
> .Number "1000-234234-35435"
>
> part of the code:
> const Delim= """"
> Do Until objFileR.AtEndofStream
> if (RegExpTest(".Number", rawline)) Then
> aStrings=split(rawline,Delim)
> WScript.Echo aStrings(1)
> end if
> Loop
>
> Any inputs would be appreciated.
>
> Thanks,
> SA
>
> =======================
>
> Why use a regular expression when instr() would do?
>
> if instr(uCase(rawline), ".NUMBER") > 0 Then
> aStrings=split(rawline,Delim)
> WScript.Echo aStrings(1)
> end if
> Loop
>
> It's a little difficult to tell you what your problem might
> be while you're concealing the error message from us.
> Maybe the array aStrings has fewer than two elements,
> so a check of uBound(aStrings) would be required.- Hide quoted text -
>
> - Show quoted text -

Yes it works. Thank you very much. So how do i get the string without
the quotes. I want the bare string for further mainpulation.

Thanks,
Sa

===============

Sorry, can't tell unless you post the full line that you're reading
from your text file. We also need to see the code you use to
process it.



Re: extracting the info from quotes!! by karsagarwal

karsagarwal
Fri May 09 18:17:22 CDT 2008

On May 9, 3:58=A0pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
> <karsagar...@gmail.com> wrote in message
>
> news:186b02c3-b8e0-46ff-883d-75e78895e449@y22g2000prd.googlegroups.com...
> On May 9, 2:56 pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
>
>
>
>
>
> > <karsagar...@gmail.com> wrote in message
>
> >news:782606fe-a06c-4309-a0e2-cea38930550c@u12g2000prd.googlegroups.com...=

> > On May 9, 2:10 pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
>
> > > <karsagar...@gmail.com> wrote in message
>
> > >news:7d97bb14-d8a1-40c3-9582-41b33005a267@t12g2000prg.googlegroups.com.=
..
>
> > > > Hi,
>
> > > > Is there a straight forward way to extract the information within
> > > > quotes only. There could be differnet types of values within quotes
> > > > and so is there a way to extract these.
>
> > > > Thanks ,
> > > > Sa
>
> > > > ..TopCell "CAP_SMD_2512_.250X.130B_.043HT"
>
> > > Here is another "straighforward" way:
> > > s =3D "..TopCell ""CAP_SMD_2512_.250X.130B_.043HT"""
> > > aStrings =3D Split(s, """")
> > > WScript.Echo aStrings(1)
>
> > > BTW, when asking such questions it is better to formulate them
> > > precisely by asking "how can I ..." instead of "Is there a way?".
> > > Someone might answer literally and say "yes, there is a way" . . .
>
> > I like your approach. Its as straightforard as you can get. But I
> > get an error.
>
> > My file contains:
> > .Number "1000-234234-35435"
>
> > part of the code:
> > const Delim=3D """"
> > Do Until objFileR.AtEndofStream
> > if (RegExpTest(".Number", rawline)) Then
> > aStrings=3Dsplit(rawline,Delim)
> > WScript.Echo aStrings(1)
> > end if
> > Loop
>
> > Any inputs would be appreciated.
>
> > Thanks,
> > SA
>
> > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>
> > Why use a regular expression when instr() would do?
>
> > if instr(uCase(rawline), ".NUMBER") > 0 Then
> > aStrings=3Dsplit(rawline,Delim)
> > WScript.Echo aStrings(1)
> > end if
> > Loop
>
> > It's a little difficult to tell you what your problem might
> > be while you're concealing the error message from us.
> > Maybe the array aStrings has fewer than two elements,
> > so a check of uBound(aStrings) would be required.- Hide quoted text -
>
> > - Show quoted text -
>
> Yes it works. Thank you very much. So how do i get the string without
> the quotes. I want the bare string for further mainpulation.
>
> Thanks,
> Sa
>
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>
> Sorry, can't tell unless you post the full line that you're reading
> from your text file. We also need to see the code you use to
> process it.- Hide quoted text -
>
> - Show quoted text -

My mistake. Anyway I followed your advice and here are the details:

The file contain the following:
=2ENumber "1003-3100-A0"
..Name "RES"
..Label "R 1K 1W 5% 2512"
...Default
..Desc "RES 1K 1W 5% 2512"
..RefPrefix "R"
..TopCell "CAP_SMD_2512_.250X.130B_.043HT"
..Modified 1186077740 ! 8/2/07 11:02 AM
..Prop "RoHS", "NO", "Text"
..Prop "Load Option", "1", "Text"
..Prop "Type", "Resistor", "Text"
..Prop "SCH VALUE", "1K", "Text"
..Prop "Value", "1K", "Real"
..Prop "Rating", "1W", "Text"
..Prop "Tolerance", "5%", "Text"


A part of the code is as follows
rawline =3D objFileR.ReadLine()

Do Until objFileR.AtEndofStream
if instr(rawline,".Number") > 0 Then
parameter=3Dsplit(rawline," ")
end if
rawline =3D objFileR.ReadLine()
Loop



So I can parse the file but I want to get the string without quotes.

Thanks,
SA





Re: extracting the info from quotes!! by Paul

Paul
Fri May 09 19:02:30 CDT 2008


<karsagarwal@gmail.com> wrote in message
news:6d2b6f49-de56-4d50-9c59-328088c7d061@l17g2000pri.googlegroups.com...
On May 9, 3:58 pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
> <karsagar...@gmail.com> wrote in message
>
> news:186b02c3-b8e0-46ff-883d-75e78895e449@y22g2000prd.googlegroups.com...
> On May 9, 2:56 pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
>
>
>
>
>
> > <karsagar...@gmail.com> wrote in message
>
> >news:782606fe-a06c-4309-a0e2-cea38930550c@u12g2000prd.googlegroups.com...
> > On May 9, 2:10 pm, "Pegasus \(MVP\)" <I....@fly.com.oz> wrote:
>
> > > <karsagar...@gmail.com> wrote in message
>
> > >news:7d97bb14-d8a1-40c3-9582-41b33005a267@t12g2000prg.googlegroups.com...
>
> > > > Hi,
>
> > > > Is there a straight forward way to extract the information
> > > > within
> > > > quotes only. There could be differnet types of values within
> > > > quotes
> > > > and so is there a way to extract these.
>
> > > > Thanks ,
> > > > Sa
>
> > > > ..TopCell "CAP_SMD_2512_.250X.130B_.043HT"
>
> > > Here is another "straighforward" way:
> > > s = "..TopCell ""CAP_SMD_2512_.250X.130B_.043HT"""
> > > aStrings = Split(s, """")
> > > WScript.Echo aStrings(1)
>
> > > BTW, when asking such questions it is better to formulate them
> > > precisely by asking "how can I ..." instead of "Is there a
> > > way?".
> > > Someone might answer literally and say "yes, there is a way" . .
> > > .
>
> > I like your approach. Its as straightforard as you can get. But I
> > get an error.
>
> > My file contains:
> > .Number "1000-234234-35435"
>
> > part of the code:
> > const Delim= """"
> > Do Until objFileR.AtEndofStream
> > if (RegExpTest(".Number", rawline)) Then
> > aStrings=split(rawline,Delim)
> > WScript.Echo aStrings(1)
> > end if
> > Loop
>
> > Any inputs would be appreciated.
>
> > Thanks,
> > SA
>
> > =======================
>
> > Why use a regular expression when instr() would do?
>
> > if instr(uCase(rawline), ".NUMBER") > 0 Then
> > aStrings=split(rawline,Delim)
> > WScript.Echo aStrings(1)
> > end if
> > Loop
>
> > It's a little difficult to tell you what your problem might
> > be while you're concealing the error message from us.
> > Maybe the array aStrings has fewer than two elements,
> > so a check of uBound(aStrings) would be required.- Hide quoted
> > text -
>
> > - Show quoted text -
>
> Yes it works. Thank you very much. So how do i get the string
> without
> the quotes. I want the bare string for further mainpulation.
>
> Thanks,
> Sa
>
> ===============
>
> Sorry, can't tell unless you post the full line that you're reading
> from your text file. We also need to see the code you use to
> process it.- Hide quoted text -
>
> - Show quoted text -

My mistake. Anyway I followed your advice and here are the details:

The file contain the following:
.Number "1003-3100-A0"
..Name "RES"
..Label "R 1K 1W 5% 2512"
...Default
..Desc "RES 1K 1W 5% 2512"
..RefPrefix "R"
..TopCell "CAP_SMD_2512_.250X.130B_.043HT"
..Modified 1186077740 ! 8/2/07 11:02 AM
..Prop "RoHS", "NO", "Text"
..Prop "Load Option", "1", "Text"
..Prop "Type", "Resistor", "Text"
..Prop "SCH VALUE", "1K", "Text"
..Prop "Value", "1K", "Real"
..Prop "Rating", "1W", "Text"
..Prop "Tolerance", "5%", "Text"


A part of the code is as follows
rawline = objFileR.ReadLine()

Do Until objFileR.AtEndofStream
if instr(rawline,".Number") > 0 Then
parameter=split(rawline," ")
end if
rawline = objFileR.ReadLine()
Loop



So I can parse the file but I want to get the string without quotes.

==========================

How about removing the quotes when you read the raw line?
rawline = Replace(objFileR.ReadLine(), Chr(34), "")

-Paul Randall



Re: extracting the info from quotes!! by James

James
Fri May 09 19:14:49 CDT 2008

<karsagarwal@gmail.com> wrote in message
news:6d2b6f49-de56-4d50-9c59-328088c7d061@l17g2000pri.googlegroups.com...
> My mistake. Anyway I followed your advice and here are the details:
>
> The file contain the following:
> .Number "1003-3100-A0"
> ..Name "RES"
> ..Label "R 1K 1W 5% 2512"
> ...Default
> ..Desc "RES 1K 1W 5% 2512"
> ..RefPrefix "R"
> ..TopCell "CAP_SMD_2512_.250X.130B_.043HT"
> ..Modified 1186077740 ! 8/2/07 11:02 AM
> ..Prop "RoHS", "NO", "Text"
> ..Prop "Load Option", "1", "Text"
> ..Prop "Type", "Resistor", "Text"
> ..Prop "SCH VALUE", "1K", "Text"
> ..Prop "Value", "1K", "Real"
> ..Prop "Rating", "1W", "Text"
> ..Prop "Tolerance", "5%", "Text"
>
>
> A part of the code is as follows
> rawline = objFileR.ReadLine()

> Do Until objFileR.AtEndofStream
> if instr(rawline,".Number") > 0 Then
> parameter=split(rawline," ")
> end if
> rawline = objFileR.ReadLine()
> Loop
>
>
>
> So I can parse the file but I want to get the string without quotes.

Using a regular expression, you can rid yourself of the quotes as well
as the loop.

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oRegEx = CreateObject("VBScript.RegExp")
oRegEx.Multiline = True
oRegEx.IgnoreCase = True

oRegEx.Pattern = "^\.Number.*?""([^""]*?)"".*?$"

sText = oFSO.OpenTextFile("sample.txt", 1).ReadAll

If oRegEx.Test(sText) Then
sParameter = oRegEx.Execute(sText)(0).Submatches(0)
End If

MsgBox sParameter
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~






Re: extracting the info from quotes!! by karsagarwal

karsagarwal
Fri May 09 20:00:52 CDT 2008

On May 9, 5:14=A0pm, "James Whitlow" <jwhitlow.60372...@bloglines.com>
wrote:
> <karsagar...@gmail.com> wrote in message
>
> news:6d2b6f49-de56-4d50-9c59-328088c7d061@l17g2000pri.googlegroups.com...
>
>
>
>
>
> > My mistake. Anyway I followed your advice and here are the details:
>
> > The file contain the following:
> > .Number "1003-3100-A0"
> > ..Name "RES"
> > ..Label "R 1K 1W 5% 2512"
> > ...Default
> > ..Desc "RES 1K 1W 5% 2512"
> > ..RefPrefix "R"
> > ..TopCell "CAP_SMD_2512_.250X.130B_.043HT"
> > ..Modified 1186077740 ! 8/2/07 11:02 AM
> > ..Prop "RoHS", "NO", "Text"
> > ..Prop "Load Option", "1", "Text"
> > ..Prop "Type", "Resistor", "Text"
> > ..Prop "SCH VALUE", "1K", "Text"
> > ..Prop "Value", "1K", "Real"
> > ..Prop "Rating", "1W", "Text"
> > ..Prop "Tolerance", "5%", "Text"
>
> > A part of the code is as follows
> > rawline =3D objFileR.ReadLine()
> > Do Until objFileR.AtEndofStream
> > if instr(rawline,".Number") > 0 Then
> > parameter=3Dsplit(rawline," ")
> > =A0 =A0 end if
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 rawline =3D objFileR.ReadLine()
> > Loop
>
> > So I can parse the file but I want to get the string without quotes.
>
> =A0 =A0 Using a regular expression, you can rid yourself of the quotes as =
well
> as the loop.
>
> '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Set oFSO =3D CreateObject("Scripting.FileSystemObject")
> Set oRegEx =3D CreateObject("VBScript.RegExp")
> oRegEx.Multiline =3D True
> oRegEx.IgnoreCase =3D True
>
> oRegEx.Pattern =3D "^\.Number.*?""([^""]*?)"".*?$"
>
> sText =3D oFSO.OpenTextFile("sample.txt", 1).ReadAll
>
> If oRegEx.Test(sText) Then
> =A0sParameter =3D oRegEx.Execute(sText)(0).Submatches(0)
> End If
>
> MsgBox sParameter
> '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~- Hide quoted=
text -
>
> - Show quoted text -

James,

I do not understand the pattern: "^\.Number.*?""([^""]*?)"".*?$"
Can you clarify?

It starts with a .Number followed by 0 or more characters except \n
followed by 0 or 1 quotes. I am not sure. Please could you clarify.


Thanks,
Sangeeta

Re: extracting the info from quotes!! by James

James
Fri May 09 20:32:49 CDT 2008

<karsagarwal@gmail.com> wrote in message
news:61920e98-36ab-452e-9e5b-22f7d01eafc5@u6g2000prc.googlegroups.com...
>
> James,
>
> I do not understand the pattern: "^\.Number.*?""([^""]*?)"".*?$"
> Can you clarify?
>
> It starts with a .Number followed by 0 or more characters except \n
> followed by 0 or 1 quotes. I am not sure. Please could you clarify.

Sure.

^ >> anchors to the beginning of a line.
\. >>looks for a period. Since period is a wildcard, it must be escaped by
a backslash
Number >> matches "Number" specifically
.*? >> non-greedy (see http://tinyurl.com/586a47) search for zero or more
characters.
''" >> matches single instance of double quotes
( >> opens the sub-match capture
[^""]*? >> non-greedy match for zero or more characters other than double
quotes. Since it is non-greedy, it will stop when it hits a set of double
quotes.
) >> closes the sub-match capture
''" >> matches single instance of double quotes
.*?$ >> non-greedy match for zero or more characters until reaching an end
of line



RE: extracting the info from quotes!! by trponder

trponder
Sat May 10 01:44:00 CDT 2008

"karsagarwal@gmail.com" wrote:

> Hi,
>
> Is there a straight forward way to extract the information within
> quotes only. There could be differnet types of values within quotes
> and so is there a way to extract these.
>
> Thanks ,
> Sa
>
> ..TopCell "CAP_SMD_2512_.250X.130B_.043HT"
>

Hi karsagarwal@gmail.com,

The following should extract all text, bound by quoted pairs, that appear in
a line. This example uses WScript.Echo to display the quoted text, so use
cscript.exe from the command prompt to test this. Replace "C:\Test.txt" with
the name of your test file.

Const ForReading = 1
Set fso = CreateObject("Scripting.FileSystemObject")
Set InFile = fso.OpenTextFile("C:\Test.txt", ForReading)
Do Until InFile.AtEndOfStream
InRec = InFile.readline
Text = Trim(InRec)
a = Split(Text, """", -1)
UBoundA = UBound(a)
For i = 1 To UBoundA Step 2
QuotedText = a(i)
If i = UBoundA and Right(Text, 1) <> """" Then QuotedText = ""
If Len(QuotedText) > 0 Then WScript.Echo QuotedText
Next
Loop
InFile.Close