web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / String manipulation to...
Power Apps
Answered

String manipulation to find letter prefix.

(0) ShareShare
ReportReport
Posted on by 3,347

I have varying strings that start with letters or numbers.  If they start with letters, I need to be able to get a len() of the letters that preceed the first number in the string.  I do not want it to count any letters that follow after the first number.  30m with chatgpt did not resolve this.  Any help?

 

Logically, this should work.  However, it errors.

 

 

Len(
 Left(
 Label58.Text,
 Find(
 Match(Label58.Text, "[0-9]"),
 Label58.Text,
 1
 ) - 1
 )
)

 

So, these text inputs should result:

 

"12345" Result = 0, or NULL

"123X42" Result = 0, or NULL

"vr12345" Result = 2

"Vr234abc" Result = 2 

Categories:
  • Verified answer
    TheRobRush Profile Picture
    11,128 Moderator on at

    I'd like to preface this with

     

    ChatGPT is so so so so so BAD at PowerApps, there are many things at which it excels, this is NOT one of them.

     

    That out of the way,

     

     

    CountRows(
     Filter(ForAll(
     Sequence(Len(Label58.Text)) As stepThrough,
    
    {Value:Last(FirstN(Split(Label58.Text,""),stepThrough.Value)).Value, Place:stepThrough.Value}), !IsNumeric(Value)
    
    &&
    Place<
     First(
    Sort(
    Filter(ForAll(
     Sequence(Len(Label58.Text)) As stepThrough,
    
    {Value:Last(FirstN(Split(Label58.Text,""),stepThrough.Value)).Value, Place:stepThrough.Value}), IsNumeric(Value)),Place,SortOrder.Ascending)).Place))

     

  • mmollet Profile Picture
    3,187 on at

    This would have taken me like 2 min if you could use/manipulate variable in a forall... Why dont they just add a normal loops functionality into power apps already. Just b/c they want it to be low code doesnt mean it cant also allow the dev to use code.. thats the one thing power apps fails miserably on imo. looping and indexing arrays would be nice to have.

  • TheRobRush Profile Picture
    11,128 Moderator on at

    Yah I really wish (since it is built on it) they would also allow us to use Java in the apps. Like not everyone would have to, but for those of us who COULD it would be nice

  • TheRobRush Profile Picture
    11,128 Moderator on at

    I am gonna give them the benefit of the doubt and guess it is to limit what we can do for app security reasons, might keep their app from getting verified on app store etc

  • martinav Profile Picture
    3,347 on at

    @TheRobRush ,

     

    Yep, this works great.  Its silly that it takes so much code for such a simple task.  This is the first time I have seen the syntax you used with "Place<"...  What is this??  Ive been using this system for several years now.  Its the first time I have seen that.

     

    Agree with chatgpt and PA.  However, it has often served well in some logic cases.  It actually does pretty well with OLE statements in Flow.  

  • TheRobRush Profile Picture
    11,128 Moderator on at

    Place is just the name of the made up column we set to the value of current pass of the forall(sequence())

    Place:stepThrough.Value

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 226 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 191 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 167

Last 30 days Overall leaderboard