mIRC Homepage
Posted By: Danko $replace before writing to file? - 25/03/05 02:41 PM
I'm using a little script to write some information to a file from what a bot says. The thing is, the bot may announce stuff like "faq-s" and i want to replace it with "faqs" when writing it to the file..

Here's the little code i use:
Code:
messed up code:P}


I've tried playing around with $replace($1-,faq-s,faqs) etc, but cant quite figure it out where to put it...

Any help? smile
Posted By: FiberOPtics Re: $replace before writing to file? - 25/03/05 02:50 PM
What have you done with the code lol, you've butchered it.

Go back to the last time you asked this, and take a look at my last post. In regex, where you put something means a lot, even 1 character different changes things.

Fex you've left out the x modifier in that second regex, so that those spaces around %a have become real spaces instead of being ignored. Instead you've put the x in the regex that doesn't need it.

And those $+() make no sense, they perform no function in your code.

I also believe the last thing I gave you were $regsubs, and not $regexes.

Anyway, use $replace(%a,faq-s,faqs) it's not the "most" fullproof method, but it'll work fine for you.

You put it in that /write line, instead of the %a.
Posted By: Danko Re: $replace before writing to file? - 25/03/05 03:01 PM
rofl, yeah i did butch it:/ :P
However, it actually worked a lot greater when i modifed it a little bit..:P
(Alltho, i removed it from my post so ppl wont see how much i mess up..hehh).

But ty, ur method worked for my purpose. blush
Posted By: RusselB Re: $replace before writing to file? - 25/03/05 08:51 PM
Yeah removing the code does keep us from seeing it, however, it also prevents us from making other, and sometimes, better suggestions.
Posted By: FiberOPtics Re: $replace before writing to file? - 25/03/05 10:06 PM
It was butchered regex code, nothing you would be able to assist with unless you have a decent knowledge of the regex syntax.
Posted By: RusselB Re: $replace before writing to file? - 25/03/05 10:15 PM
While I'm only just starting to learn about regex code, even seeing other people's mistakes and then the corrections made is helpful.
Quote:
I've learned more from my failures than my successes
© mIRC Discussion Forums