Network Automation Software We are currently migrating this forum
over to our HelpSystems domain. Please
post all new threads in our new
HelpSystems Community Portal.
Post to the HelpSystems Forum
You are not currently logged on. You must be logged on in order to post. Log on
Or Create a new account
AutoMate Discussion
Decrease font size
Increase font size
Topic Title: regex Help
Topic Summary: Regex
Created On: 10/24/2012 03:52 PM
Status: Read Only
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
View similar topics View similar topics
View topic in raw text format. Print this topic.
 10/24/2012 03:52 PM
User is offline View Users Profile Print this message

Author Icon
Journeyman (50-99)

Posts: 52
Joined: 05/09/2011

is there anybody who can help with the following problem at all, i have tried reading books and exploring websites but cannot figure out who to create this regex based on the parameters i have to work with

we recieve txt files with a large volume of content that is seperated by tags.

DP - 2009
TI - Serum and synovial fluid concentrations of CCL2 (MCP-1) chemokine in patients
suffering rheumatoid arthritis and osteoarthritis reflect disease activity.
PG - 641-6

This is just an example, but what im trying to is extract all from the TI tag across both lines

the tags before and after vary, so we cannot use this as point in the regex, so my first thought was apply the regex to capture all from TI - until the next point that contained another tag folowed by -, but as you can see their is a MCP-1 in the field i want and the regex stops short

is there a way to create a regex where it see's the start of a line, for instance our regex would start from TI - then take all on that line and if next did not start with XX - then it would take that line also until it met a new line starting with XX -

The regex has to start from TI and take all until it meets a new line that starts with an opening tag

this is the regex i have created, but as mentioned it fails as it thinks a tag is present in the line

TI Tag - TI\s\s\-\s(.|\n)*?(?=[A-Z]{2,4}\s{0,3}\-\s{0,3})

any help on this would be greatly appreciated, it is driving me mad

many thanks in advance


 10/28/2012 06:49 AM
User is offline View Users Profile Print this message

Author Icon
Artisan (200-499)

Posts: 319
Joined: 07/30/2009

Based on your example, something like the following should work:

Loop through all of the records, assigning the current text to a variable.

Using an InStr and Left statement (or Mid) to determine if there is an "-" in the first 4 fields. If one is present, then add it to the output prefixed by a new line (I.E. varOutputRecord = varOutputRecord & vbCrLf & varCurrentRecord). If one is not present, then add it to the output without a new line, which should append it to the existing record (I.E. varOutputRecord = varOutputRecord & " " & varCurrentRecord)

To eliminate any errors, it would be best if you knew what all the tags are and accounted for them, in the event that the second line actually contains text that meets the criteria above.

?? . Your Total IT Solutions Provider
?? . Business Class Hosting Services
18258 users are registered to the AutoMate Discussion forum.
There are currently 0 users logged in.
The most users ever online was 6686 on 11/01/2020 at 01:24 AM.
There are currently 2616 guests browsing this forum, which makes a total of 2616 users using this forum.

FuseTalk Enterprise Edition v4.0 - © 1999-2021 FuseTalk Inc. All rights reserved.

Sitemap Network Automation Software Blog