Jump to content

Adding a new line to the StringRegExpReplace function.


xero
 Share

Recommended Posts

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].

Link to comment
Share on other sites

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 & "<")
Link to comment
Share on other sites

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! :)
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...