-1

This is the string from which I need to do searching -

<bpmn:process id="Process_1" isExecutable="false">
<bpmn:task id="Task_15xgmrn" name="Select1Select5" extratask:entity="Select1" extratask:action="Select5"/>
<bpmn:extensionElements> <camunda_1:executionListener class="org.camunda.bpm.getstarted.loanapproval.MyTaskList" event="start"/> </bpmn:extensionElements>
<bpmn:task id="Task_0ditp3t" name="Select2Select6" extratask:entity="Select2" extratask:action="Select6" camunda_1:exclusive="false" camunda_1:asyncAfter="true" camunda_1:async="true" />
<bpmn:extensionElements> <camunda_1:executionListener class="org.camunda.bpm.getstarted.loanapproval.MyTaskList" event="start"/> </bpmn:extensionElements>
<bpmn:task id="Task_0ffkkda" name="Select2Select4" extratask:entity="Select2" extratask:action="Select4"/>
<bpmn:task id="Task_0p68hrl" name="Select3Select6" extratask:entity="Select3" extratask:action="Select6"/>
</bpmn:process>

And search result should be like this -

<bpmn:task id="anything" name="anything" extratask:entity="anything" extratask:action="anything" />

all the occurrence of the result.

I have made some changes in the search string, some attributes have been added into the second "bpmn:task" tag. And I don't want that tag to be get selected in the search result.

halfer
  • 19,824
  • 17
  • 99
  • 186
  • 6
    It's generally not a good idea to use regular expressions to process XML data. Use a real XML parser. – Barmar Sep 10 '16 at 08:16
  • Let me point you to how to do that http://stackoverflow.com/questions/17604071/parse-xml-using-javascript – Jibi Abraham Sep 10 '16 at 08:30
  • Substitute *anything* with `.*?`, all spaces with ` +` and escape slash mark `\/' if needed. – revo Sep 10 '16 at 08:31
  • Thanks friends, My job is done. I have done this for now with the help of @revo. Now I am gonna try it with xml-parser. – Gaurav Singh Sep 10 '16 at 09:23

1 Answers1

0

Am I correct that what you actually want to do is collect all the bpmn:task XML tags, because this can actually be as small as:

str.match(/<bpmn:task.+?>/g)

Or as the person in the comment pointed out

str.match(/<bpmn:task id=".*"\s*name=".*"\s*extratask:entity=".*"\s*extratask:action=".*"\s*\/>/g)

However if you want to anything more with the XML I do highly recommend using a parser.

Matt
  • 314
  • 2
  • 10