I’m trying to figure out function that will help me wrap first word in string into span.
But unfortunately no luck.
Can anyone help me please?
Many Thanks
Dom
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
One way:
[ source | try it ]
Basically, for each match (
something) you replace the first word with itself ($1) wrapped in<span>tags. The character class\wmatches letters, digits, and underscores (thus defining what a “word” is – you may need another definition).