0

Given the following iOS Shortcuts-app snippet to trim a text string up to the first n (in this case 6) characters, is there a simpler way of doing this?

Text "0123456789ABC”
Set Variable String to Text
Replace "^.{0,6}" with "" in Text (regex ON)
Replace Updated Text with "" in String
Result "012345"

Note that text "012" would result in "012"!

In the shortcuts-app, strings are not quoted as in this snippet

Trim text to first 6 characters

1 Answer 1

0

Solved.

Text "01234567890ABC”
Match "^.{0,6}" in Text
Result "012345"

Match text shortcut

4
  • 1
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Allan
    May 5 at 21:54
  • @Thinkr My original post and the more succinct answer both truncate (I said trim originally) a text string.
    – Grytr
    May 6 at 22:50
  • @Allan - I’m unclear as to how I can make it clearer. The original question was “… is there a simpler way of doing this?“. The question code has three steps and the answer code has one step.
    – Grytr
    May 6 at 22:54
  • I understand regex, but most of the folks who read this don’t. You might want to explain what you’re doing here and why.
    – Allan
    May 7 at 14:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .