0

I have the following code in Adobe LiveCycle Designer FormCalc:

if (form1.subform[0].complete_flag.rawValue == "1") then
    $.presence = "invisible";
endif

I want to use N++ find/replace with regular expression or similar to replace the above code to look like (to convert to JavaScript):

if (form1.subform[0].complete_flag.rawValue == "1") {
    this.presence = "invisible";
}

basically, in one run of find/replace, substitute the following:

then ==> {

$. ==> this.

endif ==> }

Is this possible using N++ or similar tools?

Tarek

tarekahf
  • 738
  • 1
  • 16
  • 42

1 Answers1

0

The regex: (then)|(\$)|(endif)

The replace:(?1{)(?2this)(?3})

This will work in Notepad++.

A full explanation can be found here, but if that gets unlinked, the gist of it is this:

The search looks for either of three alternatives separated by the |. Each alternative has ist own capture brackets. The replace uses the conditional form ?Ntrue-expression:false-expression where N is decimal digit, the clause checks whether capture expression N matches.

-AdrianHHH

Community
  • 1
  • 1
Harris
  • 1,775
  • 16
  • 19
  • OMG! Thanks. It worked. I searched for this extensively and I didn't find it. – tarekahf Mar 22 '16 at 22:26
  • Why there is a sad face next to your name above? – tarekahf Mar 23 '16 at 14:29
  • That's my profile picture, in the same way that you have a picture of yourself next to your name in the question (and for any answers you post). – Harris Mar 23 '16 at 16:58
  • Oh, OK. I just thought that this is related to some progress in this website. – tarekahf Mar 23 '16 at 18:35
  • How I can find and delete comment lines (single line comment using //)? I want to delete the entire line (remove it). – tarekahf Mar 23 '16 at 18:56
  • The regex would be `//.*`, and you'd replace it with a blank string. I'd suggest you consider _not_ deleting comments, though. – Harris Mar 23 '16 at 18:59