[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: parsing problem



Wonderful!!!! �Works like a charm.

A few year ago I used Perl a lot but I lost my hand at it.
Your idea of Perl helped me to fix another problem with the same file: non-breaking space.
Perl and \xA0 fixed it for me.

Thanks a lot Joao,
Bernard


On Thu, Dec 9, 2010 at 12:00 PM, Joao Ferreira gmail <joao.miguel.c.ferreira@gmail.com> wrote:
On Thu, 2010-12-09 at 11:33 -0500, Bernard Fay wrote:
> Hi,
>
>
> I have long strings to parse which have permanent and variable
> information. �Somewhere in the strings we have something like �"....
> Handle: 0x12a7 ....". �Handle is permanent and 0x12a7 is variable. �I
> wish to be able to extract the variable part (0x12a7) and assign it to
> a variable.
>

I'dd use Perl.... I love Perl.... and I don't know any other language
appropriate for this :)

jmf@squeeje:~$ cat string.txt
foo bar abc 123 Handle: 0x12a7 some more things
zoo zar Handle: 0x12a7 and more stuff

jmf@squeeje:~$ cat string.txt �| perl -e 'while (<>) {if (/Handle:\s+(\S
+)/){$line++; $your_variable = $1; print "$line $your_variable\n"; }};'

1 0x12a7
2 0x12a7


>
> Does anyone have an idea how to extract this information?
>
>
> I think awk might be the tool to use but I not too good at it yet.
>
>
> Thanks,
> Bernard
>
>




Reply to: