Regular expreession to change the data in multiple lines

Himaja

Board Regular
Joined
Oct 14, 2013
Messages
62
I have a notepad containing tags.
My requirement is to change the data as below:
My input file will have 1000+ lines with the similar data to be replaced.
Actual:

<a xlink:href="javascript:alert('XGMC021D');" xlink:title="XGMC021D">
<ellipse fill="none" stroke="black" cx="1548" cy="-898" rx="59.0322" ry="18"/>

Expected:

< elipse id="XGMC021D" style="fill:none;stroke:black; " cx="1548" cy="-898" rx="59.0322" ry="18"/>

1. In the first line, I'm removing entire data till title and replacing with < elipse id
2. First line and second line should be combined and in the second line, from < ellipse fill , it should replace with style....black;
I have code written for the first action, but for the second, I dont have.
Code in NOTEPAD:

Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objRegEx = CreateObject("VBScript.RegExp")
Set objFile = objFSO.OpenTextFile("C:\Users\XXXXX\Desktop\Sample file.svg",ForReading) 'File you want Parsed
Set outputfile = objFSO.CreateTextFile("Parsed.txt", True) 'Output File
objRegEx.IgnoreCase = True
objRegEx.MultiLine = True
objRegEx.Global = True
objRegEx.Pattern = "a xlink:href.*title"
Results = ""
Do Until objFile.AtEndOfStream
line = objFile.ReadLine
outputfile.WriteLine(objRegEx.Replace(line, "elipse id"))
Loop
objFile.Close
WScript.Echo "Done"

Can anyone pls help me in getting the above done from excel macro?
Also while trying to execute the same code in Excel macro, outfile is not getting generated.
 
Last edited:

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Since Actual is not getting displayed, I'm mentioning in quotes and code

<fdbfjdbf title="XGMC021D">
<ellipse fill="none" stroke="black" cx="1548" cy="-898" rx="59.0322" ry="18"/>
<ELLIPSE ry="18" rx="59.0322" cy="-898" cx="1548" stroke="black" fill="none" />
 
Last edited:
Upvote 0
Since Actual is not displaying:

HTML:
<a xlink:href="javascript:alert('XGMC021D');" xlink:title="XGMC021D">
<ellipse fill="none" stroke="black" cx="1548" cy="-898" rx="59.0322" ry="18"/>
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,731
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top