Abdul Rehman
Abdul Rehman

Reputation: 1794

find and replace with regex

i have following coldfusion tags that are not self closed. I need to find and replace them with / at the end if not closed. i have come up with this exp <cfset([a-z0-9 ]+) *[^/]*?> that find them all, but how to add / on them by find & replace.

 <cfset var1="#db_var1#">

Result

 <cfset var1="#db_var1#" />

Upvotes: 0

Views: 58

Answers (1)

Avinash Raj
Avinash Raj

Reputation: 174706

Regex:

(<cfset\b[^>]*)(?<!\/)>

Replace with:

\1/>

DEMO

Upvotes: 1

Related Questions