Jump to content
Sign in to follow this  
cdkid

Little help

Recommended Posts

cdkid

I was just wondering if anyone could help me out to find a RegEx pattern that would help me with this. I've never actually used RegExp before and I'm a bit confused. Basically i have strings that look like this:

1 Zone: 14 X: 337.662079 Y: -4691.141602 Z: 16.457983

but the numbers between Zone: and X: change. Basically i just want to replace everything from Z to X with ", " (a comma and a space). I figured RegExp would be a bit easier than doing StringInStr loops.

~cdkid

Edited by cdkid

AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!

Share this post


Link to post
Share on other sites
tAKTelapis

Sorry, but i am not so good with regular expressions, but i can give you this advice:

A: Rename the thread to "String RegExp: Replace Items?" or something more descriptive other than "little help" or little help is what you will get.

B: You gave the original string, can you give u a copy of it formated how you want it to come out the other side? Manually replace the items you need the script to change. Will make it easier, even with a lack of understanding Regular Expressions, i am finding it hard to visualize what it is you are after.

After that, I am think the topic will have a better chance of drawing the attention of the correct people.

Share this post


Link to post
Share on other sites
cdkid

Yeah, I renamed it from RegExp because people freak out when they see the word RegExp.... Everyone hates it, at least this way people look at it :) (It's a trap!)

before edit:

1 Zone: 14 X: 337.662079 Y: -4691.141602 Z: 16.457983

This is how i want it to look after edit..

1 , X: 337.662079 Y: -4691.141602 Z: 16.457983

All i have so far is

StringRegExp($test, "(Z*X)", 2)

this always returns just X tho, ideally i wanna be able to get

Zone: 14 X

in a variable, isolated.

~cdkid

Edited by cdkid

AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!

Share this post


Link to post
Share on other sites
SmOke_N

I was just wondering if anyone could help me out to find a RegEx pattern that would help me with this. I've never actually used RegExp before and I'm a bit confused. Basically i have strings that look like this:

1 Zone: 14 X: 337.662079 Y: -4691.141602 Z: 16.457983

but the numbers between Zone: and X: change. Basically i just want to replace everything from Z to X with ", " (a comma and a space). I figured RegExp would be a bit easier than doing StringInStr loops.

~cdkid

You could use back referencing ... but to keep it simple since you know the beginning and the end:
Global $sString, $sNew
$sString = "1 Zone: 14 X: 337.662079 Y: -4691.141602 Z: 16.457983"
$sNew = StringRegExpReplace($sString, "(?s)(?i)Zone:.*?X", "Zone:, X")
MsgBox(64, "info", $sNew)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
cdkid

Thanks so much, smoke. Really appreciate it.

~cdkid


AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!

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.