Changing entities

D

Daniel

Hello all

I need to build a program that check the sintax in a line:

SIZE (1 BYTE)

and change the correct number of bytes to the following format:

SIZE(1)

without the "BYTE" word. But, the number of bytes can be over 3 digits,
and the entitie can't have spaces but the correct number of bytes in
parentheses, like "SIZE (1024 BYTE)" to "SIZE(1024)".

Does anyone already done this or similar sintax using re?

Thank you
 
K

Kent Johnson

Daniel said:
Hello all

I need to build a program that check the sintax in a line:

SIZE (1 BYTE)

and change the correct number of bytes to the following format:

SIZE(1)

without the "BYTE" word. But, the number of bytes can be over 3 digits,
and the entitie can't have spaces but the correct number of bytes in
parentheses, like "SIZE (1024 BYTE)" to "SIZE(1024)".
'SIZE(1024)'

Kent
 
D

Daniel

Hi Kent

Thanks for your help, it worked sucessfully. I have another question, I
think it is a stupid and simple but...

I need match a regular expression, change it erasing the other strings
after this. Just like:

a = "I'm going send to out of space, find another race"

And I want to match "space" instance, and erase the other.

Thank you
 
K

Kent Johnson

Daniel said:
I need match a regular expression, change it erasing the other strings
after this. Just like:

a = "I'm going send to out of space, find another race"

And I want to match "space" instance, and erase the other.

If you mean you want to get rid of everything after 'space', this will do it:"I'm going send to out of space"

You should read this and learn to make your own regexes:
http://www.amk.ca/python/howto/regex/

Kent
 
D

Daniel

Hi Kent

This isn't work with the following line:
FieldGraphic56 ::= GraphicString EBCDIC BC= " " SIZE (56
BYTES)
'FieldGraphic56 ::= GraphicString EBCDIC BC= " " SIZE (56
BYTES)''FieldGraphic56 ::= GraphicString EBCDIC BC= " " SIZE (56
BYTES)'
Any idea? :p
 
D

Daniel

Hi Kent

This isn't work with the following line:
FieldGraphic56 ::= GraphicString EBCDIC BC= " " SIZE (56
BYTES)
'FieldGraphic56 ::= GraphicString EBCDIC BC= " " SIZE (56
BYTES)''FieldGraphic56 ::= GraphicString EBCDIC BC= " " SIZE (56
BYTES)'
Any idea? :p
 
K

Kent Johnson

Daniel said:
Hi Kent

This isn't work with the following line:
FieldGraphic56 ::= GraphicString EBCDIC BC= " " SIZE (56
BYTES)

Because the string doesn't match the pattern, can you see the difference? Do you understand what the regex is looking for?

Another good way to learn about regexes is with the Regex Demo program distributed with Python. Look for Tools\Scripts\redemo.py

Kent
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,241
Messages
2,571,219
Members
47,852
Latest member
PatriciaMu

Latest Threads

Top