|
Nat Newbie
Joined: 03 Nov 2006 Posts: 2
|
Posted: Fri Nov 03, 2006 12:29 pm
Problem with %replace |
Hi there! I apologise in advance if a solution to this has already been posted. I searched the forum but I coulden't find what I was looking for.
My problem is this:
A have a line like:
Contains the following 'abc1, def2, 123a, 456b'.
Im trying to strip the commas from this line and then make a trigger to fire off that new line but I simply can't manage to get %replace to replace the commas with a blank space. Any help is greatly appriciated.
Nat. |
|
|
|
Taz GURU
Joined: 28 Sep 2000 Posts: 1395 Location: United Kingdom
|
Posted: Fri Nov 03, 2006 12:42 pm |
#show %replace("abc1, def2, 123a, 456b",","," ")
#var test {abc1, def2, 123a, 456b}
#show %replace(@test,","," ")
both show:
abc1 def2 123a 456b
abc1 def2 123a 456b |
|
_________________ Taz :) |
|
|
|
Nat Newbie
Joined: 03 Nov 2006 Posts: 2
|
Posted: Fri Nov 03, 2006 12:52 pm |
Ah thanks, I guess I didn't explain my problem properly though!
The line:
Contains the following 'abc1, def2, 123a, 456b'.
Will quite often be different from time to time, but from what i understand I cant use a wildcard in functions.
So, what i need to do is make a trigger to replace the commas from a line like this:
Contains the following '*, *, *, *'.
but have that trigger also match this same line
Contains the following '*, *, *, *, *, *, *'.
There could be between 1 and 30(ish) *'s in the line and i need a trigger that could match that and then put each of the *'s in a seperate variable. I had tried doing it and wasnt succeeding and though that if i stripped out the commas i could get it to work but then i couldent even get %replace to work because i cant use a wildcard. I hope that makes sense! |
|
|
|
Vitae Enchanter
Joined: 17 Jun 2005 Posts: 673 Location: New York
|
Posted: Fri Nov 03, 2006 2:27 pm |
I think what Taz meant to show you in his subtle way and make you come to the conclusion on your own is use the trigger to populate the test variable
#trigger {^Contains the following ~'(*)~'.$} {#var test {%1};#echo %replace( @test, ",", "")}
Note to Taz: in reality, yours was generating:
Code: |
abc1 def2 123a 456b |
which has 2 spaces between the info rather than 1 which what I think was needed. Tho overall I don't think this answers the true question at all.
Might be needing one of those recuring thingies in the trigger...drawing a blank on what it is *mutter* was used just recently in another post. I'll see if I can find it.
Don't think i'll be any help tho cause special things in triggers and me just never seem to work. To this day I still can't get #cond to work for me.
EDIT:
reparse: execute new trigger pattern on same line as before (only usable with #COND)
SOOOO....can someone else help after this? ;-) Cause since he wants the info in a variable, i'll assume he wants to do something else with it. Which it would help if he gave a better idea of what exactly he wants and is trying to do. |
|
|
|
Taz GURU
Joined: 28 Sep 2000 Posts: 1395 Location: United Kingdom
|
Posted: Fri Nov 03, 2006 2:36 pm |
Yep of course I used " " as the replacement, should have been "" instead. Yes you're correct that the simplistic testing shows that there is nothing wrong with %replace and that if you follow some simple rules you can apply it to your required problem as you have shown.
* EDIT: no need for others to help, your answer is the correct answer, take the whole lot between the ' using a * and perform the replace on it * |
|
_________________ Taz :) |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|