0

I want to convert span elements into React Components. I would need a regex expression that treats the title property as optional. I tried it with (\s*?:title="*"?)

Works for:

<span class="fa fa-ballot-check fs-12">

let newdata = data.replace(/<span (class|className)=["'][a-z_\-][\w\-\s]*["'](\s*>|\s*\/>)/g , (n)=>{
        
          return <Symbol/>
}


Does not work for:

<span class="fa fa-ballot-check fs-12" title="Click me here"></i>

let newdata = data.replace(/<span (class|className)=["'][a-z_\-][\w\-\s]*["'](\s*?:title="*"?)(\s*>|\s*\/>)/g , (n)=>{
        
          return <Symbol/>
}

```

0 Answers0