Ask a Question related to Ruby, Design and Development.
-
Dan #1
extracting text
I have a HTML table which I would like to extract text inside a <TD>. For an
example
<TD class=12>Some text</TD>
I can write a code that detects the beginning of TD...
print line ~= "<TD class12>"
But how do I make it stop at </TD>. In the code above, I just want to print
"Some text"
thanks
Dan Guest
-
Acrobat 6 - Extracting text from 2-column PDF
I have Acrobat 6 and I wish to extract some text from an 11-page PDF which has a two-column layout. I have tried the "Save as" option, and it makes a... -
Help with extracting text
Hi everyone, How can I extract the text before the first occurrence of dot (.) or single space from the first field. This is my file LB1571... -
: Help with extracting text
Hi Zary, I have attached a sample file with the data you offered and a perl script which can be copied and pasted into the command line on win32.... -
Help with extracting text file
Hi everyone, I have a file with data similar to this ........... Exxxxx|FExxxxx|NQxxxxxx|OUxxxxxx|GExxxxxx|OVxxxxxxx|IQxxxxxxxx|ORxxxx... -
Extracting the text in a text sprite.
Hi, Is there a way to extract the text from a text sprite and place the text into a global variable? Thanks, Stef -
Dan #2
Re: extracting text
thank you
"Tim Hunter" <Tim.Hunter@sas.com> wrote in message
news:snstgv4pbjgohvs40b5nv5gn9hcdpl3s9c@4ax.com...an> Here's one answer to your question. Watch out, almost any change to
> the input will break it.
>
> irb(main):012:0> s = "<TD class=12>Some text</TD>"
> "<TD class=12>Some text</TD>"
> irb(main):013:0> m = %r{<TD [^>]+>([^<]+)</TD>}.match(s)
> #<MatchData:0x276f978>
> irb(main):014:0> p m[1]
> "Some text"
> nil
> irb(main):015:0>
>
> On Fri, 11 Jul 2003 07:46:44 -0400, "Dan" <falseflyboy@yahoo.comNONO>
> wrote:
>> >I have a HTML table which I would like to extract text inside a <TD>. For> >example
> ><TD class=12>Some text</TD>
> >
> >I can write a code that detects the beginning of TD...
> >print line ~= "<TD class12>"
> >
> >But how do I make it stop at </TD>. In the code above, I just want to>> >"Some text"
> >
> >thanks
> >
Dan Guest
-
Berger, Daniel #3
Re: extracting text
I suspect you'll want to use a parser, instead of regular expressions, to> -----Original Message-----
> From: Tim Hunter [mailto:Tim.Hunter@sas.com]
> Sent: Friday, July 11, 2003 12:36 PM
> To: [email]ruby-talk@ruby-lang.org[/email]
> Subject: Re: extracting text
>
>
> Here's one answer to your question. Watch out, almost any
> change to the input will break it.
>
> irb(main):012:0> s = "<TD class=12>Some text</TD>"
> "<TD class=12>Some text</TD>"
> irb(main):013:0> m = %r{<TD [^>]+>([^<]+)</TD>}.match(s)
> #<MatchData:0x276f978> irb(main):014:0> p m[1] "Some text"
> nil irb(main):015:0>
>
> On Fri, 11 Jul 2003 07:46:44 -0400, "Dan" <falseflyboy@yahoo.comNONO>
> wrote:
>> inside a <TD>.> >I have a HTML table which I would like to extract text> just want to> >For an example <TD class=12>Some text</TD>
> >
> >I can write a code that detects the beginning of TD...
> >print line ~= "<TD class12>"
> >
> >But how do I make it stop at </TD>. In the code above, I> >print "Some text"
> >
> >thanks
> >
parse HTML. There's an html-parser module on the RAA, though I haven't used
it myself.
Regards,
Dan
Berger, Daniel Guest
-
Peter Pan #4
Extracting Text
Hi,
I have a text field with values such as:
12345/6
12345/85
12345/127
There is always 5 characters before the /.
I would like to get all the characters on the right hand side of the /,
whether it is 1, 2, 3 characters etc. I've been playing with the position
function but can't get it right - anyone know how this can be done?
Many thanks in advance
Peter Pan Guest
-
John Weinshel #5
Re: Extracting Text
You can figure out which characters come after your delimiter (the slash) by
subtracting 6 (5 plus the slash itself) from the total number of characters
in the string:
Length(Your_Field)-6
....and you know they will always be on the right. Now you know how many
characters you want, and you can use the Right() function to retrieve their
value.
--
John Weinshel
Datagrace
Vashon Island, WA
(206) 463-1634
Associate Member, Filemaker Solutions Alliance
"Peter Pan" <splash@NOSPAMPLEASEmac.com> wrote in message
news:BBAAFF1B.1A969%splash@NOSPAMPLEASEmac.com...> Hi,
>
> I have a text field with values such as:
>
> 12345/6
> 12345/85
> 12345/127
>
> There is always 5 characters before the /.
>
> I would like to get all the characters on the right hand side of the /,
> whether it is 1, 2, 3 characters etc. I've been playing with the position
> function but can't get it right - anyone know how this can be done?
>
> Many thanks in advance
>
John Weinshel Guest
-
Peter Pan #6
Re: Extracting Text
Thanks John, that was just what I was after, works a treat.
Many thanks>
> You can figure out which characters come after your delimiter (the slash) by
> subtracting 6 (5 plus the slash itself) from the total number of characters
> in the string:
>
> Length(Your_Field)-6
>
> ...and you know they will always be on the right. Now you know how many
> characters you want, and you can use the Right() function to retrieve their
> value.
>
> --
> John Weinshel
> Datagrace
> Vashon Island, WA
> (206) 463-1634
> Associate Member, Filemaker Solutions Alliance
>
>
> "Peter Pan" <splash@NOSPAMPLEASEmac.com> wrote in message
> news:BBAAFF1B.1A969%splash@NOSPAMPLEASEmac.com...>>> Hi,
>>
>> I have a text field with values such as:
>>
>> 12345/6
>> 12345/85
>> 12345/127
>>
>> There is always 5 characters before the /.
>>
>> I would like to get all the characters on the right hand side of the /,
>> whether it is 1, 2, 3 characters etc. I've been playing with the position
>> function but can't get it right - anyone know how this can be done?
>>
>> Many thanks in advance
>>
>Peter Pan Guest
-
Glenn Schwandt #7
Re: Extracting Text
One of many ways to do this, using the / as a delimeter and not relying on
the "always 5 characters before" part:
After (calculation, text) = Replace( text field, 1, Position( text field,
"/", 1, 1), "")
"Peter Pan" <splash@NOSPAMPLEASEmac.com> wrote in message
news:BBAAFF1B.1A969%splash@NOSPAMPLEASEmac.com...> Hi,
>
> I have a text field with values such as:
>
> 12345/6
> 12345/85
> 12345/127
>
> There is always 5 characters before the /.
>
> I would like to get all the characters on the right hand side of the /,
> whether it is 1, 2, 3 characters etc. I've been playing with the position
> function but can't get it right - anyone know how this can be done?
>
> Many thanks in advance
>
Glenn Schwandt Guest
-
Glenn Schwandt #8
Re: Extracting Text
Other possibilities:
= Middle( text field, Position( text field, "/", 1, 1), 9999)
= Right( text field, Length( text field) - Position( text field, "/", 1,
1))
= Substitute( text field, Left( text field, Position( text field, "/", 1,
1)), "")
All of which utilize the Position function. My original "Replace" solution
and the "Middle" solution above require only two functions each, so I would
assume they would be the most efficient.
"Glenn Schwandt" <schwandtgat@aoldot.com> wrote in message
news:voaomfod70b2f6@corp.supernews.com...position> One of many ways to do this, using the / as a delimeter and not relying on
> the "always 5 characters before" part:
>
> After (calculation, text) = Replace( text field, 1, Position( text field,
> "/", 1, 1), "")
>
> "Peter Pan" <splash@NOSPAMPLEASEmac.com> wrote in message
> news:BBAAFF1B.1A969%splash@NOSPAMPLEASEmac.com...> > Hi,
> >
> > I have a text field with values such as:
> >
> > 12345/6
> > 12345/85
> > 12345/127
> >
> > There is always 5 characters before the /.
> >
> > I would like to get all the characters on the right hand side of the /,
> > whether it is 1, 2, 3 characters etc. I've been playing with the>> > function but can't get it right - anyone know how this can be done?
> >
> > Many thanks in advance
> >
>
Glenn Schwandt Guest



Reply With Quote

