Tuesday, 15 March 2011

regex - Using variable in regular expression in Python -


I have looked at several posts and other forums to get the answers related to my question, but nothing what I want should I As a head, I am new to programming and I do not have the original foundation which will be mostly.

I know that Bash is good with a little dragon and RE.

I am trying to create Python scripts using RE to parse data and give me an output I want.

My output will have 4 values, all will be generated from one line. With any defined delimiter, the reading line is thrown together (hence the reason for my program)

To find one of the 4 values, I have to say that search for 123 - and then give me everything but wait here df5 . 123 - is not static, but defined by a regular expression that works, the same goes for df5 I specified both in a variable of RE Have done How can I use those variables, what do I want between the two ... please let me know what it does understand.

  import then start = '123' 'stop =' df5 'regex = re.compile ('{}}. (*?) {1} format (re-space), Re.escape (stop)))   

Note that for these example strings < Call> re.escape () calls are not required, but it is important if your delimiters ever use regex (. , * , + < / Code>, ? etc.).

No comments:

Post a Comment