1

Is there a way to parse multiple RGB values from a string? In what way should the colours be coded?

Eg.

$string = "foobar [rgb:123abc] some other text and another color: [rgb:ffeecc]"

I want [rgb:xxxxxx] to be replaced with something like <div style="background: #xxxxxx;">&nbsp;</div>

1 Answer 1

3

You could use this regex to pick up the pattern...

/\[rgb:([0-9a-f]{6})\]/i
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.