Jump to content
Sign in to follow this  
xero

Adding a new line to the StringRegExpReplace function.

Recommended Posts

xero

Hello! I have a very quick query..

I have a little trouble with using the StringRegExpReplace function. I am trying to edit some text in a .txt file, and what I want it to do is basically split one line of text into 2 lines at certain points. For example, if I have this:

<hello>blah</hello><hello>blah</hello>

I want to turn it into this:

<hello>blah</hello>
<hello>blah</hello>

Now, I am getting quite far with working out how to do it (have a few different ideas...) but the problem is, how to either 1/ send the {ENTER} command, or somehow make the script start a new line at the given place.

Hope this makes sense, and sorry if it doesn't!

Many thanks,

[xero].

Share this post


Link to post
Share on other sites
seandisanti

Hello! I have a very quick query..

I have a little trouble with using the StringRegExpReplace function. I am trying to edit some text in a .txt file, and what I want it to do is basically split one line of text into 2 lines at certain points. For example, if I have this:

<hello>blah</hello><hello>blah</hello>

I want to turn it into this:

<hello>blah</hello>
<hello>blah</hello>

Now, I am getting quite far with working out how to do it (have a few different ideas...) but the problem is, how to either 1/ send the {ENTER} command, or somehow make the script start a new line at the given place.

Hope this makes sense, and sorry if it doesn't!

Many thanks,

[xero].

i wouldn't even go with regex on this one, just StringReplace.

$mashed = "<hello>blah</hello><hello>blah</hello>"
$split = StringReplace($mashed,"><",">" & @cr & "<")

Share this post


Link to post
Share on other sites
xero

i wouldn't even go with regex on this one, just StringReplace.

$mashed = "<hello>blah</hello><hello>blah</hello>"
$split = StringReplace($mashed,"><",">" & @cr & "<")
You're a saviour, thankyou.. If I can figure this out now (if my brain holds up until I get home..!) this will save me many hours of painful typing.. Thanks! :)

Share this post


Link to post
Share on other sites
seandisanti

You're a saviour, thankyou.. If I can figure this out now (if my brain holds up until I get home..!) this will save me many hours of painful typing.. Thanks! :)

np, happy to help

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.