String Manipulation

A forum for macro code snippets to be used in writing other macros. Post routines or .inc files here only, completed macros go to the Macro Depot. MQ2Data format only!

Moderator: MacroQuest Developers

User avatar
billthecat
a lesser mummy
a lesser mummy
Posts: 64
Joined: Sun Jan 30, 2005 8:58 pm

String Manipulation

Post by billthecat » Mon Jun 06, 2005 12:04 am

I'm looking for a good way to filter certain characters out of a given string. Suppose I start out with a string:

"frag men d'ary a`la word"

What's the best way of filtering it down to:

"fragmendaryalaword"

I figured I could clean it up in 3 passes by looking for 1 of the 3 characters I'm removing and picking out the string segments that happen between what I'm looking to remove with a command like string.token[1,'], and then just concatenating them together.

That seems kinda ugly though. I was not able to find any string methods in the docs to do this and so far searching the boards hasn't shown anything either. Any other methods I've missed?
"If you think nobody cares, try missing a couple of payments"

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Mon Jun 06, 2005 1:41 am

--
<Thedude> I have to say your there retarded one.

User avatar
billthecat
a lesser mummy
a lesser mummy
Posts: 64
Joined: Sun Jan 30, 2005 8:58 pm

Post by billthecat » Mon Jun 06, 2005 4:49 pm

Okaaaay, maybe I should rephrase that.

The methods listed in that section of the docs are the ones that allowed me to concoct the manner of filtering I already have. I'm using the Length, Right, and Arg/Token methods to pull the string apart into chunks that I have to append back together again.

A filter method would just nuke the characters I want to remove, and close the gaps.

Is there a way to use regular expressions in a script?
"If you think nobody cares, try missing a couple of payments"

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Mon Jun 06, 2005 5:03 pm

No.

There is a perl plugin floating around. I'm not sure if it works.

Otherwise, you could write your own plugin to do what you want.
--
<Thedude> I have to say your there retarded one.

xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: String Manipulation

Post by xyilla » Fri May 23, 2025 11:25 pm


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: String Manipulation

Post by xyilla » Sat May 24, 2025 12:02 am


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: String Manipulation

Post by xyilla » Sat May 24, 2025 12:39 am


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: String Manipulation

Post by xyilla » Sat May 24, 2025 12:40 am


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: String Manipulation

Post by xyilla » Sat May 24, 2025 12:41 am


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: String Manipulation

Post by xyilla » Sat May 24, 2025 12:42 am


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: String Manipulation

Post by xyilla » Sat May 24, 2025 12:43 am


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: String Manipulation

Post by xyilla » Sat May 24, 2025 12:44 am


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: String Manipulation

Post by xyilla » Sat May 24, 2025 12:46 am


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: String Manipulation

Post by xyilla » Sat May 24, 2025 12:47 am


xyilla
naggy
naggy
Posts: 33673
Joined: Sun Feb 23, 2025 5:36 am

Re: String Manipulation

Post by xyilla » Sat May 24, 2025 12:48 am