• 0

[PHP] Regex trouble


Question

ok im trying to make a Preg replace for a m8 and its not working

heres what he wants

to make function to change the colour of the words using the same way as the Quake 3 engine

basicly if i type

^5{^4J^5R^4G^5}^4S^5mifffy

ill get

the same colouring as in my sig

colours:

^1 Red

^2 Green

^3 Yellow

^4 Blue

^5 Light-Blue

^6 Purple

^7 White

^8 Black

thx Ric

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

\^(\d)([^\^]*?)

I think that will do it, with the subpatterns for the number and the word :)

Might even be simpler to do with just some string functions, though...

Link to comment
Share on other sites

  • 0

Then don't use RegEx :D

No, seriously, this is fairly easy to parse out without using regex. Use strpos() to find the location of a ^ and use the next character to find the color choice. Rather simple :)

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.