English 中文(简体)
reg reg
原标题:Parsing FIX protocol in regex?

我需要打上含有FIX礼宾信息的标志。

每一行都包含头盔信息(日间、伐木水平、终点),其次是FIX有效载荷。

我用reg子把头盔信息传播到指定团体。 例如:

 <?P<datetime>d{2}/d{2}/d{2} d{2}:d{2}:d{2}.d{6}) (?<process_id>d{4}/d{1,2})s*(?P<logging_level>w*)s*(?P<endpoint>w*)s*

接着,我去过FIX有效载荷(^A是各标签的分离器),例如:

8=FIX.4.2^A9=61^A35=A...^A11=blahblah...

我需要从中提取具体的标签(例如,从35升至“A”或从11升至“blahblah”),忽视所有其他障碍——基本上我需要忽略在“35=A”之前的任何内容,以及“11=blahblah”之后的任何内容,然后忽略任何内容等等。

然而,我确实知道,有一间图书馆能够使每一方都相传(http://source.kentyde.com/fixlib/overview),但是,我希望采用一种简单的做法,尽可能利用这一办法,因为我确实只需要几个方面。

Is there a good way in regex to extract the tags I require?

Cheers, Victor

最佳回答

Use a regex tool like expresso or regexbuddy.
Why don t you split on ^A and then match ([^=])+=(.*) for each one putting them into a hash? You could also filter with a switch that by default won t add the tags you re uninterested in and that has a fall through for all the tags you are interested in.

问题回答

无需在“x01”后进行过滤。 如果你只想标34,49和56(MsgSeqNum、SenderCompId和CompId),你可以:

dict(re.findall("(?:^|x01)(34|49|56)=(.*?)x01", raw_msg))

如果你知道ender子没有能够造成任何小reg的嵌入性数据,那么像这样的小reg会起作用。 具体来说:

  1. No Raw Data fields (actually combination of data len and raw data like RawDataLength,RawData (95/96) or XmlDataLen, XmlData (212,213)
  2. No encoded fields for unicode strings like EncodedTextLen, EncodedText (354/355)

处理这些案件需要很多额外时间。 我使用一种习俗 p子,但即使是上文提到的固定法,也是错误的。 但是,如果你的数据明确了这些例外情况,则上述标准应归还贵方希望的田地。

www.un.org/esa 我先把上述规定作为依据,但应当加以修订,以便最后的对等要素成为“条形”(?=x01)>。 解释可在以下网址查阅:https://stackovermission.com/问题31/198950/parsing- set-message-in-regex1/199578 p31199575>answer 。

^ A is actual x{01}, thats Just how it show up in vim. 顺便说一句,我通过在海尔1号上分立,然后按“=”分立,在第二批中,阵列的价值[0]是“Ta”和价值 ***。





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签