Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Regex expression in find/replace fails

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Regex expression in find/replace fails

    I have put together an example regex which I need for parsing replacing a ton of print statements in my code:

    RegExr is an online tool to learn, build, & test Regular Expressions (RegEx / RegExp).


    I have tried to paste that into the find/replace window but I get 'unexpected end in regular expression quoted string'. I have tried the regex with three online parsers and it works fine. The same works here as well:

    http://regexstorm.net/tester (copy paste the input and pattern from here)

    So what am I doing wrong? Can someone give me an example of how I would accomplish this? I have a ton of these types of statements and don't feel like doing this manually.

    Thanks,

    Michael

    #2
    Hello molecool,

    Thank you for your note.

    These online regex tools are going to be out of the scope of what our scripting desk supports, but if you could provide a sample NinjaScript script along with the strings you’d like to replace, I can try to be of assistance.

    I look forward to your reply.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_AlanP View Post
      Hello molecool,

      Thank you for your note.

      These online regex tools are going to be out of the scope of what our scripting desk supports, but if you could provide a sample NinjaScript script along with the strings you’d like to replace, I can try to be of assistance.

      I look forward to your reply.
      Thanks Alan, well the sample is actually in the link I provided, but let me post it here:

      Sample script:

      Print("\n****** " + Times[1][0] + ": " + instrumentName + " Canceling stop/target and exiting short position...", PrintLevel.DEV);

      Matching Expression:

      (if \(PrintLevel <= PrintLevel.DEV\) )(.*)"

      Replacement Expression:

      $2", PrintLevel.DEV

      Desired outcome:

      Print("\n****** " + Times[1][0] + ": " + instrumentName + " Canceling stop/target and exiting short position...", PrintLevel.DEV);

      It works fine in any online regex engine I've tried. But I'm having issues making it work in the find/replace panel of the Ninja8 editor.

      Comment


        #4
        Quick update: Ninja support tells me that this is too tough a nut to crack in the NT8 editor BUT it works in VisualStudio. Which I can happily confirm :-)

        Comment


          #5
          Hello molecool,

          Were you also working with someone else on this issue that gave you that answer?

          The matching expression is missing from the sample script, and the Sample Script matches the Desired Outcome, so if you could provide more detail that would be helpful. Are you suggesting a bug?

          I look forward to your reply.
          Alan P.NinjaTrader Customer Service

          Comment


            #6
            Hello Molecool,

            The issue with the editor has to do with ActiPro.

            Even though a double-quote is not a standard regex character like [ ? or +, it has to be escaped with ActiPro.

            If you change the end to \", you can capture the quote.

            You can see,



            Please let us know if you need more information.
            Alan P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by alifarahani, Today, 09:40 AM
            3 responses
            15 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by RookieTrader, Today, 09:37 AM
            4 responses
            17 views
            0 likes
            Last Post RookieTrader  
            Started by PaulMohn, Today, 12:36 PM
            0 responses
            4 views
            0 likes
            Last Post PaulMohn  
            Started by love2code2trade, 04-17-2024, 01:45 PM
            4 responses
            40 views
            0 likes
            Last Post love2code2trade  
            Started by junkone, Today, 11:37 AM
            3 responses
            23 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X