Network Automation Software
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: "Replace Text" using 'Enhanced' Regex replaces match with query
Topic Summary: "Replace Text" using 'Enhanced' Regex puts *condition* string instead of replacement string
Created On: 09/13/2012 10:12 AM
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.
 09/13/2012 10:12 AM
User is offline View Users Profile Print this message

Author Icon
Apprentice (20-49)

Posts: 29
Joined: 11/17/2005

I'm sure this is something daft I've overlooked, and hope someone sees this and can suggest a simple correction. I'm not the sharpest RegEx tool in the drawer.

I'm parsing an XML file, and need to cleanse an attribute. At the point I use the Replace function, I have already created the properly cleansed string, but each occurrence has a different length and values. There are about 300,000 of them.

(Note that I forgot the forum formatting would rip all the meaningful characters out of the XML string, so I've attached it in a tiny screenshot file)

I realize I could use a different technique and find the unique text sequence and then back through the string from there until I found the preceding vbCrLf, then look forward until I found the subsequent vbCrLf, and then use the byte index values for each to concatenate the head, cleansed string, and tail together. But I'd love it if I could so it this way.

Fingers crossed! on Windows 7 or W2K8R2

 Category Survey

Click for full image
Click for larger image

Edited: 09/13/2012 at 10:24 AM by DLJNA
 09/13/2012 12:07 PM
User is offline View Users Profile Print this message

Author Icon
Apprentice (20-49)

Posts: 29
Joined: 11/17/2005

Not solved, but worked around.

I fell back to my normal approach for this scenario:

    Create a couple extra variables to hold text, and create a couiple more variables still to hold numbers (byte index values)

    Read the whole buffer (text file) into the normal variable (%ScratchBuffer%).

    I'm still finding the RegEx string exactly as above, and populating the result into %ScratchBufferHeadEndIndex%

    Get text from %ScratchBuffer%, starting at position 1 and continuing for %ScratchBufferHeadEndIndex% bytes and populate %GoodXMLhead%

    Assign a temporary text variable called %ScratchBufferTempValue% with Mid(%ScratchBuffer, starting at %ScratchBufferHeadEndIndex% bytes)

    Find the first occurrence of %vbCrLf% in this truncated temporary text variable, and populate %ScratchBufferTailStartIndex% with it.

    Populate %GoodXMLtail% with Mid(%ScratchBufferTempValue%, starting at byte %ScratchBufferTailStartIndex%)

    Clear any values to %ScratchBufferTempValue%

    Insert the text %CleansedAttribute% at the end of %GoodXMLhead% and populate it to %ScratchBufferTempValue%

    Insert the text %GoodXMLtail% at the end of %ScratchBufferTempValue% and populate it to whatever normal variable destination it previously had.

I know you can use Insert to populate the same variable being Inserted into, and I know you can sometimes concatenate several fields together in a single line, but with version 6.x I always found it a little inconsistent, so took the long route.

If anyone still knows the answer, I'd still appreciate it, to learn for future use. I just thought I'd post this in case someone else got stuck with the same issue.

Also, just hammered this out. Apologies up front for any messiness.

 Category Survey
 09/13/2012 12:14 PM
User is offline View Users Profile Print this message

Author Icon
Supreme Guru (1000+)

Posts: 8883
Joined: 03/30/2005

I confirm the issue

 Category Survey
AutoMate 6 version:
Windows version:

Task Steps: (Right click, Select All, Copy to copy to the clipboard. Steps can then be pasted into the AutoMate Task Builder)

Jean Delfosse - Automate Beta Tester
Win7 Pro 64 bits -Win XP Pro SP3 32 bits - AM8, AM7, BPA10, BPA9, BPA8, BPA7, AM6 Enterprise, AM4
18257 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 638 guests browsing this forum, which makes a total of 638 users using this forum.

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

Sitemap Network Automation Software Blog