Split a string based on Regex

@fudi5 In given string “sdghabeddghabuioiyabdfjsk” i want find position of last occurrence “ab” using regex.

Hi @Manjuts90

use this method in you assign activity :

[target string].ToString.LastIndexOf("ab")

And the result positon(Int32) should plus 1 .

@lainh sorry for repeatedly asking samething but i asked solution by using regex.

@Manjuts90
sorry ,I colud not get you ,because I think it can not write a single regex formula to get the last position.

I do write a xaml with only the regex.match method,but not only a single formula.
If you suppose that , I will upload it later.

I think you’ve received a ton of help and hand-holding here, it would be best for you to take some time to learn a bit on your own. If everyone simply tells you what to do and you copy+paste it into your workflow, then you won’t be learning anything and will likely get stuck on something similar to in the future. Instead of asking for someone to simply do your work for you, it is instead much better to do the following:

  1. Explain what you’re trying to achieve
  2. Give us some code or explanation of what you’ve tried already and what part isn’t working. Give exact errors if applicable

If you at least show SOME effort of trying, people will be much more likely to be helpful and you will learn much more by actually attempting to figure out some of it yourself.

Manjuts90:

In given string “sdghabeddghabuioiyabdfjsk” i want find position of last occurrence “ab” using regex.

This question doesn’t make sense. You say you want the last position - why? We’ve tried showing you the string.lastindexof(string) and you repeatedly say you don’t want that, without any explanation why. Then, you say you want the last match for a specific phrase such as “ab”. However, if you are simply searching for that exact phrase, why would it matter whether it was the last instance of that phrase? Either way, the phrase would be the same.

1 Like

@Dave i have asked just one question not many questions as you saying, May be my question was not clear.

511764.pdf (293.0 KB)
Hai

i need to get text from this pdf certificate no and etc etc but i cant extract how could i do it.please i need help from you

Please Suggest Any solution bellow scenario

Hello @ChinnapuReddy

I would check if there are any hidden characters between the words first by placing it in notepad or something and moving the cursor between the characters; like if it takes 2 cursor movements to get from “o” to “T” then there is a hidden newline character between it. If the hidden character is there then you can simply use the .Split() method.

However, that is most likely not the case, so we can explore a Regex solution.
We can split by a capital letter like this:

System.Text.RegularExpressions.Regex.Split("VolvoTataMaruthiMahindraBenz","(?=[A-Z])").Skip(1)

I am using the “?=” so it looks for A-Z but doesn’t include it, otherwise you will remove the character from the split. Also, I use .Skip(1) so it removes the first item since the “V” will add an item at the start.

As a test you can join the array in a message box:

String.Join(",",System.Text.RegularExpressions.Regex.Split("VolvoTataMaruthiMahindraBenz","(?=[A-Z])").Skip(1))

I hope this is helpful.

Regards.

2 Likes

Thanks for reply , i will try it and i will get back to you with my result or feed back