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