mIRC Home    About    Download    Register    News    Help

Print Thread
#118870 29/04/05 08:42 PM
Joined: Sep 2004
Posts: 200
I
IR_n00b Offline OP
Fjord artisan
OP Offline
Fjord artisan
I
Joined: Sep 2004
Posts: 200
is there any way to insert text to a sting, for example:
'abcdefgh'

if i could insert a letter/symbol before e' and then delete e:
'abcd(symbol/letter)efgh'
then
'abcd(symbol/letter)fgh'

any help would be apriciated cool

#118871 29/04/05 08:44 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Are you trying to replace the "e"? If so, $replace works.

More specific information about what you're trying to do might help with deciding the best way for your to insert/replace the text.


Invision Support
#Invision on irc.irchighway.net
#118872 29/04/05 09:08 PM
Joined: Sep 2004
Posts: 200
I
IR_n00b Offline OP
Fjord artisan
OP Offline
Fjord artisan
I
Joined: Sep 2004
Posts: 200
if i have somthing like (definition of work in html stuff)
Code:
 <LI><b><i>noun</i>:</b> activity directed toward making or doing something <blockquote><font color=green>Example: <i>"She checked several points needing further work"</i></font></blockquote> 

and i want to replace the last </i> with somthing else but not the first one, and it needs to work for many different ones.

#118873 29/04/05 10:28 PM
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
Here's some code for in your script:
Code:
var %txt = &lt;LI&gt;&lt;b&gt;&lt;i&gt;noun&lt;/i&gt;:&lt;/b&gt; ...&lt;blockquote&gt;&lt;font color=green&gt;Example: &lt;i&gt;"She checked several points needing further work"&lt;/i&gt;&lt;/font&gt;&lt;/blockquote&gt;
var %regex = [color:blue]regex[/color]
var %result, %b = $regsub(%txt,%regex,\1[color:green]replacement text[/color],%result)
; the replaced string is now in %result


The %txt contains whatever you need to change, you can change replacement text to about anything, except \ or $ followed by a number or commas since those are special characters for pcre or mIRC. Yes, the \1 is needed or you'll lose everything before the </i> you want to change smile

Replace regex with:
/(.*)<\/i>/i to replace last </i>
/(<\/i>.*?)<\/i>/i to replace second </i>
/((?:<\/i>.*?){2})<\/i>/i to replace third (=2-1) </i>
/(.*)<\/i>/i to replace first </i>

If you want to know more about regex, download pcre.txt (PCRE man pages)from www.pcre.org since that's what mIRC uses (skip the first parts, interesting part starts at PCRE REGULAR EXPRESSION DETAILS). Google has some more general info about them, some mIRC scripting sites too...

#118874 01/05/05 02:33 PM
Joined: Sep 2004
Posts: 200
I
IR_n00b Offline OP
Fjord artisan
OP Offline
Fjord artisan
I
Joined: Sep 2004
Posts: 200
ok i dont realy understand regex that mutch, but if i were to simply put it im trying to strip HTML from that quote using mIRC scripting, and i need an identifyier/alias that returns eather the text replacing a character in the text string with another character $remove wouldnt work for every one
forgot to give you an example:
<LI><b><i>noun</i>:</b> a means of <a href=d?u=serving&loc=fdef style='{color:#880000; text-decoration:none;}'>serving</a> <blockquote><font color=green>Example: <i>"There's no help for it"</i></font></blockquote>
<LI><b><i>noun</i>:</b> a resource
<LI><b><i>noun</i>:</b> a person who contributes to the <a href=d?u=fulfillment&loc=fdef style='{color:#880000; text-decoration:none;}'>fulfillment</a> of a need or <a href=d?u=furtherance&loc=fdef style='{color:#880000; text-decoration:none;}'>furtherance</a> of an <a href=d?u=effort&loc=fdef style='{color:#880000; text-decoration:none;}'>effort</a> or purpose <blockquote><font color=green>Example: <i>"They hired additional help to finish the work"</i></font></blockquote>
<LI><b><i>noun</i>:</b> the activity of <a href=d?u=contributing&loc=fdef style='{color:#880000; text-decoration:none;}'>contributing</a> to the <a href=d?u=fulfillment&loc=fdef style='{color:#880000; text-decoration:none;}'>fulfillment</a> of a need or <a href=d?u=furtherance&loc=fdef style='{color:#880000; text-decoration:none;}'>furtherance</a> of an <a href=d?u=effort&loc=fdef style='{color:#880000; text-decoration:none;}'>effort</a> or purpose <blockquote><font color=green>Example: <i>"Offered his help in unloading"</i></font></blockquote>
<LI><b><i>verb</i>:</b> give help or assistance; be of service <blockquote><font color=green>Example: <i>"Everyone helped out during the earthquake"</i></font></blockquote>
<LI><b><i>verb</i>:</b> <a href=d?u=contribute&loc=fdef style='{color:#880000; text-decoration:none;}'>contribute</a> to the <a href=d?u=furtherance&loc=fdef style='{color:#880000; text-decoration:none;}'>furtherance</a> of <blockquote><font color=green>Example: <i>"This money will help the development of literacy in developing countries"</i></font></blockquote>
<LI><b><i>verb</i>:</b> be of use <blockquote><font color=green>Example: <i>"This will help to prevent accidents"</i></font></blockquote>
<LI><b><i>verb</i>:</b> improve the condition of <blockquote><font color=green>Example: <i>"These pills will help the patient"</i></font></blockquote>
<LI><b><i>verb</i>:</b> improve; change for the better <blockquote><font color=green>Example: <i>"New slipcovers will help the old living room furniture"</i></font></blockquote>
<LI><b><i>verb</i>:</b> always used with a negative <blockquote><font color=green>Example: <i>"I can't help myself--I have to smoke"</i></font></blockquote>
<LI><b><i>verb</i>:</b> help to some food; help with food or drink <blockquote><font color=green>Example: <i>"I served him three times, and after that he helped himself"</i></font></blockquote>
<LI><b><i>verb</i>:</b> take or use <blockquote><font color=green>Example: <i>"She helped herself to some of the office supplies"</i></font></blockquote>
see how the <a href> is different on every highlited word? thats a problem because if i just use $remove it dosent remove the extra word

Last edited by IR_n00b; 01/05/05 02:37 PM.
#118875 01/05/05 08:05 PM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Quote:
ok i dont realy understand regex that mutch, but if i were to simply put it im trying to strip HTML from that quote using mIRC scripting,


alias -l nohtml { var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;) | return %x }

^ Thats someone elses from another thread, but it seemed to work pretty well on the site he /she was using it to strip the html from as i recall.

#118876 01/05/05 09:08 PM
Joined: Sep 2004
Posts: 200
I
IR_n00b Offline OP
Fjord artisan
OP Offline
Fjord artisan
I
Joined: Sep 2004
Posts: 200
it works! i didnt test it 100%, but it worked!
thx dave!

#118877 01/05/05 10:05 PM
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
It's difficult to give the right answer to your problem if you ask about another problem frown

DaveC's answer it probably good enough, maybe need some $replaces for special characters (&nbsp is replaced, but there's similar stuff that's less used)

#118878 02/05/05 02:07 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
True, but this alias has been around and used for a long time. In almost all situations, it works perfectly for what people need. smile


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard