• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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:

    https://regexr.com/3qj1q

    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,

            https://www.actiprosoftware.com/comm...lar-expression

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

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by iq200, Today, 09:57 AM
            1 response
            18 views
            0 likes
            Last Post NinjaTrader_ChristopherD  
            Started by _Zero_, Today, 09:19 AM
            1 response
            10 views
            0 likes
            Last Post NinjaTrader_Jim  
            Started by GLFX005, Today, 09:05 AM
            3 responses
            24 views
            0 likes
            Last Post NinjaTrader_RyanS  
            Started by meandthetrio, Today, 09:03 AM
            1 response
            5 views
            0 likes
            Last Post NinjaTrader_PatrickG  
            Started by peakythomas, Today, 08:34 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_Tyler  
            Working...
            X