Layer7 API Management

 View Only
  • 1.  substring function

    Posted Jun 14, 2017 08:03 AM

    Hi,

     

    Is there any assertion for creating substrings with variable length of a given context variable in the api gateway? 

    --> substring(beginIndex, endIndex)

     

    My guess was doing this with regex with the following pattern: 

    ^.{0,100}

    This matches only the first 100 characters and it works, but we need the character amount to be set dinamically:

    ^.{0,${maxLength}}

    Here we could set the context variable maxLength to 100 or whatever.

    But this never matches to any given string because the regular expression assertion treats the input from the context variable maxLength as literals e.g. 

    ^.{0,\1\0\0}


  • 2.  Re: substring function
    Best Answer

    Posted Jun 14, 2017 11:14 AM

    Found it out by myself. I can use the xpath function substring($string, $start, $end)



  • 3.  Re: substring function

    Posted Oct 24, 2018 08:19 AM

    Could you please help me with which assertion we have to use to configure substring(......)



  • 4.  Re: substring function

    Posted Oct 24, 2018 09:00 AM

    Hi,

     

    I created an encapsulated assertion with the assertion "Response must match Xpath" like this:



  • 5.  RE: Re: substring function

    Posted Jun 17, 2020 12:06 PM
    Hi!
    When I have already created what you indicate, how can I call them within my API GW project?
    How can I put the string parameters and the start and end positions?

    ------------------------------
    Applications Architect
    B-Secure
    ------------------------------