Jump to content

Modify a string


Recommended Posts

I have 2 problems.

1st is that I'm not a programer so I'm learning as I go so I appreciate any help offered.

2nd is that I have a string that I want to modify before writing it or doing additional items with it.

Starting string

item1

item2item3item1

item2item3item1

item2item3item1

What I want to change it to

item1

item2

item3

item1

item2

item3

etc...

I'm taking an original file and parsing out the data I don't want in it and this is what I'm left with. I cannot figure out how to further format it properly. My thoughts are it would be by just adding a line feed character but I cannot seem to get that to work.

Again thanks for any help offered.

Link to comment
Share on other sites

That's where I've been at. Here's what I'm using right now.

$info1 = StringRegExpReplace($info, "$", " {"&@CRLF&"}$")

Basically I want to find a given string and add a line feed but I just cannot seem to get the syntax right. I've tried a few differnt things without success.

I've been able to get it to add a space where I need by doing the following so I figure my issue is just understanding ascii characters and how to add them.

$info1 = StringRegExpReplace($info, "$", " $")

Edited by brea
Link to comment
Share on other sites

Try this:

#include <Array.au3>
$string = "item1" & @CRLF & _
         "item2item3item1" & @CRLF & _
         "item2item3item1" & @CRLF & _
         "item2item3item1"
$aRegExp = StringRegExp($string, "(?i)item[\d]+", 3)
_ArrayDisplay($aRegExp)

BR,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

$info1 = StringRegExpReplace($info, "(?m:^|\n)(.+\v+)", "$1" & @CRLF)

EDIT: look in my signature for a tool to test the expressions.

Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

So basically what I see is that I need to read up on regular expressions to understand them better right?

I can copy your work but that won't help me the next time I need to do something similar.

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