Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

111
Views
How to wrap words with anchor tags in react if string contains certain symbols

Hey guys am working on blog content with #hashtags and @mentions,i want a to check for all the words in a string if this words have @mention or #tags wrap them with anchor tags, so incase i have something like "hello @watchdog are you with @example and #trends #football"

so i want to wrap to have something like @watchdog @exmaple #exmaple

am using react js

export const text = (text) =>{
const [linktext,setLinkText] =  useState('')

useEffect(()=>{
},[])

return (
   <div>{text}</div>
)
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

export const text = (text) =>{
const [linktext,setLinkText] =  useState("hello @watchdog are you with @example and #trends #football")

useEffect(()=>{
},[])

return (
   <div>{linktext.split(" ").map(word => (
         (word.includes("@") || word.includes("#"))
           ?
         <a>{word} </a>
        :
        <p>{word}</p>
    ))}</div>
)
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!