Skip to content

regex are not working to match values. #137

Description

@delhipnr

import textfsm
import io
template_data = """Value Name (\w+)
Value Age (\d+)

Start
^${Name}
^${Age} -> Record
"""

input_data = """
Alice
37
Smith
42
"""
template_data = io.StringIO(template_data)
fsm = textfsm.TextFSM(template_data)
result = fsm.ParseText(input_data)

print("Parsed Headers:")
pprint.pprint(fsm.header)

print("\nParsed Data:")
pprint.pprint(result)

I want to extract name and age through ^(\w+)$\n^(\d+)$ regex and it is working but if I use textfsm Why it is not giving data in simple format?

response:
[
{
"Name": "456",
"Age": ""
}
]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions