mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
so for example if we take this

l[style co:#040404;b;]i[style co:#080808;b;]k[style co:#0C0C0C;b;]e [style co:#141414;b;]t[style co:#181818;b;]h[style co:#1C1C1C;b;]i[style co:#202020;b;]s [style co:#282828;b;]o[style co:#2C2C2C;b;]n[style co:#303030;b;]e [style co:#383838;b;]l[style co:#3C3C3C;b;]a[style co:#404040;b;]l[style co:#444444;b;]a[style co:#484848;b;]l[style co:#4C4C4C;b;]a[style co:#505050;b;]l[style co:#545454;b;]a[style co:#585858;b;]l

i want to remove the style tags and strip it down so it actually returns 'like this one lala..,,'

Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Code:
alias striptags { return $regsubex($$1,/\[ $iif($prop == strict,style \40) .+?\]/gx,) }


I've added a .strict property to make it only remove [style] tags. If you suppress .strict it will remove all tags, including [b], [i], etc..

To see the difference try this example:

Code:
alias test {
  var %tags = [b][i]l[style co:#040404;b;]i[style co:#080808;b;]k[style co:#0C0C0C;b;]e [style co:#141414;b;]t[style co:#181818;b;]h[style co:#1C1C1C;b;]i[style co:#202020;b;]s [style co:#282828;b;]o[style co:#2C2C2C;b;]n[style co:#303030;b;]e [style co:#383838;b;]l[style co:#3C3C3C;b;]a[style co:#404040;b;]l[style co:#444444;b;]a[style co:#484848;b;]l[style co:#4C4C4C;b;]a[style co:#505050;b;]l[style co:#545454;b;]a[style co:#585858;b;]l
  echo -a Strict: $striptags(%tags).strict 
  echo -a Normal: $striptags(%tags)
}

Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
works perfect thanks hixxy

Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
i found some problems because its only supposed to remove style tags for e.g

Code:
  var %tags = [[]root[][][[[]]

  echo -a Normal: $striptags(%tags)


Normal: root]

it should give [[]root[][][[[]] becasue there arent any style tags in it

sorry i should have been more clear in my first post. i only want to remove the style tags which look like
[style attributes]some text here[/style]

Last edited by pouncer; 23/09/07 06:28 PM.
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Read my bloody post.. I added a .strict property for that exact reason and I even explained it.

Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
ahh i see now, sorry.

and thanks again!

Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
another problem:

var %tags = :[style ff:Comic Sans MS;co:#4B0082;b;]hellooo[/style]

echo -a $striptags(%tags).strict gives me

:hellooo[/style]

any idea why it puts the extra [/style] on?

Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
I told it to only remove [style ...] tags, this will work for those too:

Code:
alias striptags { return $regsubex($$1,/\[ $iif($prop == strict,(?:style \40|/style)) .*?\]/gx,) }

Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
thanks, im still getting some style echos though, for example

Code:
alias striptags { return $regsubex($$1,/\[ $iif($prop == strict,(?:style \40|/style)) .*?\]/gx,) }

alias test {
  var %tags = :[Style ff:Maiandra GD;co:#81CB41;b;](F)(¯`·.[style co:#ff0000;b;i;](L)(¯`·.(F)(r*)[style co:#4eee94;b;](\\\\_pony_1_//)(r*)[style co:#ff0000;b;i;](F).·´¯)(L)[style co:#7d26cd;b;i;].·´¯)(F)[/style]

  echo -a Strict: $striptags(%tags).strict
}


it echos

Strict: :[Style ff:Maiandra GD;co:#81CB41;b;](F)(¯`·.(L)(¯`·.(F)(r*)(\\\\_pony_1_//)(r*)(F).·´¯)(L).·´¯)(F)

Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Change /gx to /gix

Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
thanks hixxy can i ask what the gix do?

Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
/g = makes $regex() return the number of matches, rather than just 1 for a match and 0 for a nonmatch.

/i = case-insensitive, so /A/i would match even if you applied it to "aaa"

/x = ignore spaces in the expression, so /a a/x is equivalent to /aa/ .. I basically used it here because it's easier than using $+


Link Copied to Clipboard