How to split n chars of a string?
Is there a way in fastly to extract first and last n chars from a string? I am quite new to fastly and so far I couldn't find a way to do this
-
Hi
The closest we have is to use a regular expression to capture the characters.
Check this fiddle for an example of how you can accomplish what you've described. Run it to see the output based on the input string.
Have a look at this Regular Expression Cheat Sheet for more details on using regexes on our platform.
What are you looking to accomplish exactly?
-
Quick update for you! We also have a native substring function you can use for this: https://docs.fastly.com/vcl/functions/substr/
`
substr("abcdefg", -4, -3)`
is"de"
Please sign in to leave a comment.
Comments
3 comments