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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to efficiently pro...
Power Automate
Suggested Answer

How to efficiently process characters using Power Automate Flow?

(2) ShareShare
ReportReport
Posted on by 22
Hi
How to efficiently process characters using Power Automate Flow? 
for example , I'd like to remove all characters except letters and numbers. ?
 
)73283727e327xf -> 73283727e327xf
323232dwe/89DF-> 323232dwe89DF
 
 
Thanks
Categories:
I have the same question (0)
  • Chriddle Profile Picture
    8,441 Super User 2025 Season 2 on at
    Here are two ways to achieve this
     
    Left side:
    Create an array of characters and filter for items that are letters or numbers.
    Advantage: You don't need to specify the characters to remove.
    Disadvantage: You need an extra action (Filter array)
     
    chunk(outputs('Compose'), 1)
    toLower(item())
    join(body('Filter_array'), '')
     
     
    Right side:
    An alternative to using nested replacement functions.
    Advantage: It's just one expression.
    Disadvantage: You need to know and define the characters to remove (e.g. () /\@#$%&*).
     
    xpath(
    	xml('<foo></foo>'),
    	concat('translate("', outputs('Compose'),'", "() /\@#$%&*", "")')
    )
     
     
     
    Results:
  • Chriddle Profile Picture
    8,441 Super User 2025 Season 2 on at
    If you don't know the characters to remove (flow below, left side) but have a maximum string length (e.g. 14),
    you can still achieve this with just one expression.
    ​​​But it looks a bit ugly ;)
     
    concat(
    	if(
    		and(
    			greater(length(outputs('Compose')), 0),
    			contains('abcdefghijklmnopqrstuvwxyz0123456789', substring(toLower(outputs('Compose')), 0, 1))
    		),
    		substring(outputs('Compose'), 0, 1),
    		''
    	),
    	if(
    		and(
    			greater(length(outputs('Compose')), 1),
    			contains('abcdefghijklmnopqrstuvwxyz0123456789', substring(toLower(outputs('Compose')), 1, 1))
    		),
    		substring(outputs('Compose'), 1, 1),
    		''
    	),
    	if(
    		and(
    			greater(length(outputs('Compose')), 2),
    			contains('abcdefghijklmnopqrstuvwxyz0123456789', substring(toLower(outputs('Compose')), 2, 1))
    		),
    		substring(outputs('Compose'), 2, 1),
    		''
    	),
    	if(
    		and(
    			greater(length(outputs('Compose')), 3),
    			contains('abcdefghijklmnopqrstuvwxyz0123456789', substring(toLower(outputs('Compose')), 3, 1))
    		),
    		substring(outputs('Compose'), 3, 1),
    		''
    	),
    	if(
    		and(
    			greater(length(outputs('Compose')), 4),
    			contains('abcdefghijklmnopqrstuvwxyz0123456789', substring(toLower(outputs('Compose')), 4, 1))
    		),
    		substring(outputs('Compose'), 4, 1),
    		''
    	),
    	if(
    		and(
    			greater(length(outputs('Compose')), 5),
    			contains('abcdefghijklmnopqrstuvwxyz0123456789', substring(toLower(outputs('Compose')), 5, 1))
    		),
    		substring(outputs('Compose'), 5, 1),
    		''
    	),
    	if(
    		and(
    			greater(length(outputs('Compose')), 6),
    			contains('abcdefghijklmnopqrstuvwxyz0123456789', substring(toLower(outputs('Compose')), 6, 1))
    		),
    		substring(outputs('Compose'), 6, 1),
    		''
    	),
    	if(
    		and(
    			greater(length(outputs('Compose')), 7),
    			contains('abcdefghijklmnopqrstuvwxyz0123456789', substring(toLower(outputs('Compose')), 7, 1))
    		),
    		substring(outputs('Compose'), 7, 1),
    		''
    	),
    	if(
    		and(
    			greater(length(outputs('Compose')), 8),
    			contains('abcdefghijklmnopqrstuvwxyz0123456789', substring(toLower(outputs('Compose')), 8, 1))
    		),
    		substring(outputs('Compose'), 8, 1),
    		''
    	),
    	if(
    		and(
    			greater(length(outputs('Compose')), 9),
    			contains('abcdefghijklmnopqrstuvwxyz0123456789', substring(toLower(outputs('Compose')), 9, 1))
    		),
    		substring(outputs('Compose'), 9, 1),
    		''
    	),
    	if(
    		and(
    			greater(length(outputs('Compose')), 10),
    			contains('abcdefghijklmnopqrstuvwxyz0123456789', substring(toLower(outputs('Compose')), 10, 1))
    		),
    		substring(outputs('Compose'), 10, 1),
    		''
    	),
    	if(
    		and(
    			greater(length(outputs('Compose')), 11),
    			contains('abcdefghijklmnopqrstuvwxyz0123456789', substring(toLower(outputs('Compose')), 11, 1))
    		),
    		substring(outputs('Compose'), 11, 1),
    		''
    	),
    	if(
    		and(
    			greater(length(outputs('Compose')), 12),
    			contains('abcdefghijklmnopqrstuvwxyz0123456789', substring(toLower(outputs('Compose')), 12, 1))
    		),
    		substring(outputs('Compose'), 12, 1),
    		''
    	),
    	if(
    		and(
    			greater(length(outputs('Compose')), 13),
    			contains('abcdefghijklmnopqrstuvwxyz0123456789', substring(toLower(outputs('Compose')), 13, 1))
    		),
    		substring(outputs('Compose'), 13, 1),
    		''
    	)
    )
     
  • Suggested answer
    Chriddle Profile Picture
    8,441 Super User 2025 Season 2 on at
    ...or you use an expression with two nested xpath functions (the inner one determines which characters should be deleted, the outer one deletes them).
     
    xpath(
    	xml('<foo></foo>'),
    	concat(
    		'translate("', outputs('Compose'), '", "',
    		xpath(
    			xml('<foo></foo>'),
    			concat('translate("', outputs('Compose'),'", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", "")')
    		), '", "")'
    	)
    )
  • Chriddle Profile Picture
    8,441 Super User 2025 Season 2 on at
    I did a performance test comparing the XPath expression to the huge Concat expression (100,000 times).
    Xpath is much faster (even faster than creating the 100,000 random strings initially):
     
     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard