Strengfunktioner giver brugerne mulighed for at konvertere strenge, strengtegn, formatere strenge og mere. De bruges flittigt til at konvertere data til andre kilder. I dette selvstudium gennemgår vi nogle komplicerede String-funktioner, der kan bruges i Microsoft-flows – understrengen og indexOf - funktionerne.
Indholdsfortegnelse
Power Automate String Funktion: Understreng
Lad os først diskutere understrengsfunktionen. Dette bruges, hvis vi ønsker, at brugeren skal indtaste deres fornavn og efternavn, og vi kun ønsker at returnere fornavnet eller efternavnet.
Starten på den angivne position.
Lad os prøve det i dette eksempelflow, som jeg tidligere har oprettet. Vi fjerner dette aktuelle indhold, som jeg har indstillet til meddelelsesteksten .

Vælg understrengsfunktionen under valget Strengfunktioner . Dette indeholder tekst, startindeks og længdeparametre .
![Power Automate String Functions: Substring og IndexOf Power Automate String Functions: Substring og IndexOf]()
Når du har klikket, skal du gå til fanen og derefter vælge Input 1.
![Power Automate String Functions: Substring og IndexOf Power Automate String Functions: Substring og IndexOf]()
Lad os sætte startIndex til 0, da vi vil have det til at starte ved 0. Så skal det vise 5 bogstaver.
![Power Automate String Functions: Substring og IndexOf Power Automate String Functions: Substring og IndexOf]()
For at opsummere, vil denne funktion tage hvad end input 1 er. Så vil det kun give os tegnene fra teksten mellem nul og fem. Lad os nu klikke på OK.
![Power Automate String Functions: Substring og IndexOf Power Automate String Functions: Substring og IndexOf]()
Lad os også kombinere det med sammenkædningen. Så klik på Concat- funktionen.
![Power Automate String Functions: Substring og IndexOf Power Automate String Functions: Substring og IndexOf]()
Klip ( Ctrl + X ) hele understrengsfunktionen .
![Power Automate String Functions: Substring og IndexOf Power Automate String Functions: Substring og IndexOf]()
Indsæt det derefter i concat -funktionen.
![Power Automate String Functions: Substring og IndexOf Power Automate String Functions: Substring og IndexOf]()
![Power Automate String Functions: Substring og IndexOf Power Automate String Functions: Substring og IndexOf]()
For det første argument, lad os skrive " Brugerens fornavn er ".
![Power Automate String Functions: Substring og IndexOf Power Automate String Functions: Substring og IndexOf]()
Klik derefter på Opdater.
![Power Automate String Functions: Substring og IndexOf Power Automate String Functions: Substring og IndexOf]()
Klik til sidst på Gem .
![Power Automate String Functions: Substring og IndexOf Power Automate String Functions: Substring og IndexOf]()
Test af understrengsfunktionen
Lad os nu teste flowet.
![Power Automate String Functions: Substring og IndexOf Power Automate String Functions: Substring og IndexOf]()
Vi bruger bare dataene fra mine tidligere kørsler.
![Power Automate String Functions: Substring og IndexOf Power Automate String Functions: Substring og IndexOf]()
Mit input under mine tidligere løb var Henry . Det er derfor, det viste " Brugerens fornavn er: Henry ".
![Power Automate String Functions: Substring og IndexOf Power Automate String Functions: Substring og IndexOf]()
Derfor fungerede understrengsfunktionen , som den skulle. Lad os prøve at teste flowet igen og indtaste et nyt input. Lad os skrive Shelley til input 1 og køre flowet.
![Power Automate String Functions: Substring og IndexOf Power Automate String Functions: Substring og IndexOf]()
Som vi kan se, viste den bare " shell " i stedet for " Shelley ". Det er fordi vi specificerede, at det kun skulle vise 5 tegn. Og det er sådan, substring -funktionen fungerer.
![Power Automate String Functions: Substring og IndexOf Power Automate String Functions: Substring og IndexOf]()
Power Automate String Funktion: IndexOf
Lad os nu diskutere, hvad power automate indexOf- funktionen gør.
Funktionen indexOf finder indekset eller positionen af et tegn i en given streng på en måde, hvor der ikke er store og små bogstaver.
Denne kraftautomatiseringsstrengfunktion kræver to parametre: strengen, der indeholder værdien, og værdien, der skal søges i indekset for. Lad os nu gå tilbage til vores flow, og lad os tilføje en ny tekstinput .
![Power Automate String Functions: Substring og IndexOf Power Automate String Functions: Substring og IndexOf]()
Til dette input ønsker vi, at brugeren skal indtaste sin e-mail.
![Power Automate String Functions: Substring og IndexOf Power Automate String Functions: Substring og IndexOf]()
Vi ønsker kun at returnere tegnene før tegnet @ og ikke hele e-mailen. For at gøre det, lad os først fjerne det oprindelige udtryk, som vi oprettede.
![Power Automate String Functions: Substring og IndexOf Power Automate String Functions: Substring og IndexOf]()
Vi skal kombinere understrengen med funktionen indexOf . Under fanen Udtryk skal du vælge funktionen understreng .
![Power Automate String Functions: Substring og IndexOf Power Automate String Functions: Substring og IndexOf]()
Vælg derefter Input 3 under fanen Dynamisk indhold .
![Power Automate String Functions: Substring og IndexOf Power Automate String Functions: Substring og IndexOf]()
For startIndex- parameteren, lad os sætte 0. Længden skal være indekset for @ -tegnet. Klik på indexOf- funktionen.
![Power Automate String Functions: Substring og IndexOf Power Automate String Functions: Substring og IndexOf]()
Vælg Input 3 under fanen Dynamisk indhold .
![Power Automate String Functions: Substring og IndexOf Power Automate String Functions: Substring og IndexOf]()
Lad os derefter specificere det tegn, som vi vil finde i teksten. I dette tilfælde er det tegnet " @ ". Klik derefter på OK .
![Power Automate String Functions: Substring og IndexOf Power Automate String Functions: Substring og IndexOf]()
Test af flowet
Lad os nu gemme og teste flowet.
![Power Automate String Functions: Substring og IndexOf Power Automate String Functions: Substring og IndexOf]()
Lad os udføre en ny udløserhandling og klik derefter på Gem og test .
![Power Automate String Functions: Substring og IndexOf Power Automate String Functions: Substring og IndexOf]()
Indtast blot hvad som helst for de andre input. Hvad angår input 3 , lad os skrive " nicholas@hotmail.com ". Klik derefter på Kør flow .
![Power Automate String Functions: Substring og IndexOf Power Automate String Functions: Substring og IndexOf]()
Når vi tjekker vores Slack, vil vi se, at den har skrevet ordet " nicholas ". Ved at kombinere disse to funktioner vil flowet altid returnere tegnene før @ -tegnet. Dette gør vores udtryk mere dynamisk.
![Power Automate String Functions: Substring og IndexOf Power Automate String Functions: Substring og IndexOf]()
Konklusion
I dette indlæg diskuterede vi de almindelige anvendelsestilfælde for strengfunktioner. Vi kan også bruge visse strengfunktioner sammen med de andre, såsom at kombinere substrengen og indexOf - funktionerne. Vi gør dette for at få mere specifikke tegn i teksten, især hvis længden af strengen ændres. Det er bestemt nyttigt og effektivt at lave vores udtryk for den slags tilfælde.
Der er mange andre Power Automate-strengfunktioner , som du kan bruge til dine flows. Vi vil diskutere nogle af dem i vores andre blogs. Forhåbentlig var du i stand til at forstå brugen og vigtigheden af disse to strengfunktioner.
Alt det bedste,
Henrik