burnedfaceless
asked on
Remove characters from a string
I'm writing my first object oriented script that spells triads and chords derived from the major, harmonic minor or jazz minor.
I need to remove the characters ♭ ♯ 𝄪 𝄫 from a note.
So I need to remove the ♯ from D♯ and return a D.
What is the best way to do this?
I need to remove the characters ♭ ♯ 𝄪 𝄫 from a note.
So I need to remove the ♯ from D♯ and return a D.
What is the best way to do this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
$str = preg_replace("/[^A-Za-z0-9 ?! ]/","",$str);
this will allow only letters numbers and spaces in your string
this will allow only letters numbers and spaces in your string
Oops - for some reason, I read this as a C# question - not a PHP one. Here's the PHP version of it:
$note = "D♯";
$baseNote = $note[0];
ASKER
It's cool man I was in C# before I was suspended when marijuana was found in my dorm. I knew what you were saying I was smoking more marijuana instead of coding.
Open in new window