I need a help to parse the characters inside those brackets:
[]
{}
<>
{|}
<|>
For example, I have this string variable (Japanese):
$question = "この<部屋|へや>[に]{椅子|いす}[が]ありません";
Expected result in HTML:
Description
1) This is a particle. I will convert all word inside
[]
into HTML tag. Example:[に]
will be converted into<span style="color:blue">に</span>
. A full sentence can have multiple[]
. Note: I understand how to use str_replace.2 and 4) This is normal kanji word which will be used as a question to the user. A full sentence can only have one
{}
.3 and 5) This is normal kanji text. A full sentence can have multiple
{}
.2, 3, 4, and 5) They will converted into Ruby html tags. Sometimes they will not have a
|
separator, which is not mandatory. From what I understand, I just need to explode the|
characters. If explode return false or|
not exist, I will use original value. Note: I understand how to use ruby tags (rb and rt).
My question
How do I parse characters 1-5 I mentioned above with PHP? What keyword I need to start?
Thanks.