Regular Expression: Changes HTML Attributes Value to some pattern

Posted by brain90 on Stack Overflow See other posts from Stack Overflow or by brain90
Published on 2010-05-15T15:46:30Z Indexed on 2010/05/15 16:04 UTC
Read the original article Hit count: 211

Filed under:
|
|

Dear Engineers, I'm a newbie in RegEx

I have thousands html tags, have wrote like this:
<input type="text" name="CustomerName" />
<input type="text" name="SalesOrder"/>

I need to match every name attribute values and convert them all to be like this:
CustomerName -> cust[customer_name]
SalesOrder -> cust[sales_order]

So the results will be :
<input type="text" name="cust[customer_name]" />
<input type="text" name="cust[sales_order]" />

My best try have stuck in this pattern: name=\"[a-zA-Z0-9]*\"
-> just found name="CustomerName"

Please guide me wrote some Regular Expression magics to done this, I'm using Netbeans PDT. Thanks in advance for any pointers!.

© Stack Overflow or respective owner

Related posts about regex

Related posts about html