0

I want to use regular expression in Notepad++ to find expressions as follows:

form1.subform[0].linestatus1.rawValue

or

form1.subform.linestatus1.rawValue

or, the general pattern is as follows (Adobe LiveCycle FormCalc expression):

element1.element2[index1].element3[index2].element4.element_n.propName

where the [index1] and [index2] are optional.

Also, the match should exclude the following (Adobe LiveCycle JavaScript expression):

xfa.resolveNode("form1.subform.linestatus1").rawValue xfa.resolveNode("form1.subform[0].linestatus1").rawValue

Or the general pattern is (must not match the following): xfa.resolveNode("element1.element2[index1].element3[index2].element4").propName

where propName could be any of the following fixed names: - rawValue - access - formattedValue ...etc.

The objective eventually is to be able to convert the the the from the first Syntax (FormCalc) to the second one (JavaScript) using find/replace.

Appreciate your help.

Note: so far, I was able to use this expression but not enough:

\b(?!xfa\.resolveNode\(\")([a-zA-Z_][a-zA-Z0-9_]*(\[([0-9]+)\])?\.)*rawValue

EDIT: I think I found the solution but I am not sure why it is working. Check this:

(^|[\s(])(?!xfa\.resolveNode\(")(([a-zA-Z][a-zA-Z0-9]*(\[[0-9]+\])?\.?)*)(\.rawValue)

and here is a working sample:

https://regex101.com/r/nY9vT1/9

Appreciate it if someone could explain why it is working and if there is a better solution?

EDIT: Here is a simplified regx. The last one was crashing in certain cases due to complexity:

Find:   (?:(^|[\s;(])(?!xfa\.resolveNode\(\".+\"\))((?:[a-zA-Z0-9_\.\[\]]*))(\.(?:rawValue|access|fillColor)))
Replace:    \1xfa.resolveNode\("\2"\)\3

Check it here.

Tarek

tarekahf
  • 738
  • 1
  • 16
  • 42

0 Answers0