Can someone help me with some RegEx?

General discussions about Advanced Find and Replace
Post Reply
kjustian
Posts: 6
Joined: Fri Jan 20, 2006 11:22 pm

Can someone help me with some RegEx?

Post by kjustian »

I need to search for the following formats of strings

C_OP700_Panelview_424
C_OP700_Panelview_00
C_OP700_Panelview_10_00
C_OP700_Panelview_06_10
C_OP700_Panelview_32
C_OP700_Panelview_10_11
C_OP700_Panelview_500
C_System_Panelview_424
C_System_Panelview_00
C_System_Panelview_10_00
C_System_Panelview_06_10
C_System_Panelview_32
C_System_Panelview_10_11
C_System_Panelview_500

and then modify them to this ...

{[PLC_05052]C_OP1300_Panelview[424]}
{[PLC_05052]C_OP1300_Panelview[0]}
{[PLC_05052]C_OP1300_Panelview[10].0}
{[PLC_05052]C_OP1300_Panelview[6].10}
{[PLC_05052]C_OP1300_Panelview[32]}
{[PLC_05052]C_OP1300_Panelview[10].11}
{[PLC_05052]C_OP1300_Panelview[500]}
{[PLC_05052]C_System_Panelview[424]}
{[PLC_05052]C_System_Panelview[0]}
{[PLC_05052]C_System_Panelview[10].0}
{[PLC_05052]C_System_Panelview[6].10}
{[PLC_05052]C_System_Panelview[32]}
{[PLC_05052]C_System_Panelview[10].11}
{[PLC_05052]C_System_Panelview[500]}

Note the hard part (for me) to figure out is the search backwards
and especially the extensive use of reserved characters in the
modified strings. Then to make it a little more complicated, the
zero padding must be removed as well. Anybody up for a challenge?

Abacre
Site Admin
Posts: 1223
Joined: Mon Jan 31, 2005 5:32 pm

Post by Abacre »

Hi,

You should put 4 pairs into the batch grid:
1.
Search for:
(C_\w*)_Panelview_00
Replace with:
$1_Panelview_0

(it will remove first position zero padding)

2.
Search for:
(C_\w*)_Panelview_(\d+)_00
Replace with:
$1_Panelview_$2_0

(it will remove second position zero padding)

3.
Search for:
(C_\w*)_Panelview_(\d+)
Replace with:
{[PLC_05052]$1_Panelview[$2]}

(for conversion string having one number)

4.
Search for:
(C_\w*)_Panelview_(\d+)_(\d+)
Replace with:
{[PLC_05052]$1_Panelview[$2].$3}

(for conversion string having two numbers)


So put 4 pairs into the batch grid and run it.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

kjustian
Posts: 6
Joined: Fri Jan 20, 2006 11:22 pm

Wow thanks for the quick reply!

Post by kjustian »

This is excellent service (BTW I just bought this program!)
Thanks again!!!

Abacre
Site Admin
Posts: 1223
Joined: Mon Jan 31, 2005 5:32 pm

Post by Abacre »

Thank you!
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

Post Reply