google / google/textfsm

regex are not working to match values.

Open
#137 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.2k
Forks
194
PR merge metrics
No merged PRs in 30d

Description

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": ""
}
]

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.