Reputation: 7244
I want to match dynamicCast(header.get_0('(0008,0020)'), Q$String_$1)
:
header.containsKey('(0008,0020)')?(dateString = dynamicCast(header.get_0('(0008,0020)'), Q$String_$1)[0]):header.containsKey('(0008,0022)')?(dateString = dynamicCast(header.get_0('(0008,0022)'), Q$String_$1)[0]):header.containsKey('(0008,0021)')?(dateString = dynamicCast(header.get_0('(0008,0021)'), Q$String_$1)[0]):header.containsKey('(0008,0023)') && (dateString = dynamicCast(header.get_0('(0008,0023)'), Q$String_$1)[0]);
I managed to make it work with this regex
dynamicCast\(header.get.*, Q\$(String_|int_)\$1\)
The problem is, it matches the whole block. What is the proper regex magic spell to get the four matches I want?
I'm currently rewriting auto-generated JavaScript using a regex using Ruby. I'm then replacing each match with
header.get_0('(0008,0020)')
One a problem is I have to match some different flavors, inside the method get_0
there are many different possibilities. I might need to match every single possibility, and then, why use regex?
dynamicCast(header.get_0('(0028,' + element + ')'), Q$String_$1)
Upvotes: 1
Views: 48
Reputation: 13650
You can use the following to match:
dynamicCast\(header\.get_0\('\([^)]+\)'\), Q\$(?:String_|int_)\$1\)
See DEMO
Upvotes: 2