Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

preg_replace

0 views
Skip to first unread message

edwingt

unread,
Aug 6, 2011, 9:08:57 AM8/6/11
to
Hello I'm trying to make a preg_replace for musical chords, my code is
this

preg_replace("/(DO|RE|MI|FA|SOL|LA|SI|A|B|C|D|E|F|G)[#b]?[\-|$|M|min|
dim|dom|sus|aug|add|7|9|11|13|b5|b11|b13|\+4]?/", "<span class='chord'>
$0</span>", $item['#markup'])

Problem 1
The code replace all chods but also returns this
Fuerte it matchs <span class='chord'>Fu</span>erte I think that is
matching 'F' and the 'u; of 'aug'
<span class="chord">Co</span>ro I think is matching 'C' and 'o'

How can I tell preg_replace to match just the entire word like 'min',
'aug', 'add' etc...

Problem 2
if I add \b to force a space after the expresion like
preg_replace("/(DO|RE|MI|FA|SOL|LA|SI|A|B|C|D|E|F|G)[#b]?[\-|$|M|min|
dim|dom|sus|aug|add|7|9|11|13|b5|b11|b13|\+4]?\b/", "<span
class='chord'>$0</span>", $item['#markup'])
It dosent match any chord

Thanks in advance

0 new messages