cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

count "slash" and cut after that --> reg expr.

Jump to solution

Hi All,

 

i have a question.

I want to count the slashes within a field and cut the Input Text after that.

I tried to use the "regular expression" action, but i dont know how to use the Regular Expression Language (I understood that the action uses the Microsoft .NET regular expression syntax).

 

e.g. input text

http://xxx.yyy.zz/aaa/bbb/123/456/567/allitems.aspx

 

in my case, i need the string "http://xxx.yyy.zz/aaa/bbb" (without the last slash)

 

Can anyone help me?

 

 

Greetings

Labels: (1)
0 Kudos
Reply
4 Replies
Workflow Hero

Re: count "slash" and cut after that --> reg expr.

Jump to solution

This could fit >>> http://[a-z./]+

You have some online tools for regular expressions. Here is one of them >>> RegExr: Learn, Build, & Test RegEx

0 Kudos
Reply
Workflow Hero

Re: count "slash" and cut after that --> reg expr.

Jump to solution

Hi,

Your question is not fully clear to me. What do you mean by "counting"? Do you need the result of that count or the match that includes exactly that (or fewer) count of path fragments ending with slashes? For the latter you can use the {3} or the {3,5} syntax.

looks like you could use something like (?Smiley Sad?:http|https|ftp|file):\/\/|\\{2}){1}([^/?#]+\/){1,3}

Don't forget that URLs may start with other protocol schema monikers such as ftp, file, https, etc. Users might also use the UNC notation for network shares (\\server\share).

You are right about the RegEx engine, and Fernando provided a link to a nice online tool to learn and test your expressions on varied inputs.

0 Kudos
Reply
Workflow Hero

Re: count "slash" and cut after that --> reg expr.

Jump to solution

Hi Guys, thanks for your help.

I used the following and it works for my case perfect! http://[0-9a-z.]+/[[0-9a-z.]+/[0-9a-z.]+

Thank you

Greeting, Murat

0 Kudos
Reply
Workflow Hero

Re: count "slash" and cut after that --> reg expr.

Jump to solution

I'm sure you understand that your regex is fragile, unless you've configured it to be case insensitive somehow rather than [a-z] I'd use \w for "word" characters and \d for digits.

0 Kudos
Reply