Removing word

Hi team,

I have an input like
Input 1 : THE MISSION IMPOSSIBLE
Bot should check the first word is if it contains ‘THE’ so it has to remove the word ‘THE’ and output should be - MISSION IMPOSSIBLE
Input 2 : THE THE THE MISSION IMPOSSIBLE
Output should be - MISSION IMPOSSIBLE
Help needed with sample code.

1 Like

grafik

1 Like

Using regex for a later replace (Regex.Replace)
Search for THE’s which are on Start of line / Text
grafik

Can you bit be more elaborate on this as i am new to this. I need to to use activity Match and then Replace? need step by step to understand

grafik

Use an assign Activity
LeftSide = strCleansed
RightSide: Regex.Replace(strText,Pattern,"").Trim()

Ensure following:
grafik

1 Like

The above given solution is working fine only when the word THE is mentioned in caps. It should work irrespective of the input is in caps or in small characters.

1 Like

simple use replace its verry simple
input Variable.tolower.replace(“the”,"").tostring

Sorry for the changes…
The above given solution is working fine only when the word THE is mentioned in caps. It should work irrespective of the input is in caps or in small characters. How to edit in the current code - RightSide: Regex.Replace(strText,Pattern,"").Trim()

use my code above it will work

Use Regex.Replace(strText.ToUpper(),Pattern,"").Trim()

@Chetan
Input : THE THE MISSION THE IMPOSSIBLE
Output should be : MISSION THE IMPOSSIBLE
Your code removes THE whereever it is found in the line.
It should remove only THE found initially as mentioned in above example.
Also same for the word AND also. Word AND also should be removed.

1 Like

Use this Code below
Variable.tostring.toLoweCase.replace(“the”,"").replace(“and”,"")

If get the solution please mark it as solution

Regards
Chethan P

If input like this use regex because u need the in between mission the impossible
Regex.Replace(strText,Pattern,"").Trim()

and use replace variable.tostring.tolower.replace(“and”,"")

Regex.Replace(strText,Pattern,"").Trim()
and use replace variable.tostring.tolower.replace(“and”,"")
If i use the above code 2 cases are getting failed

  1. THE the AND THE MISSION THE IMPOSSIBLE
    Expected Res: MISSION THE IMPOSSIBLE
    Actual Res: the MISSION THE IMPOSSIBLE
  2. THE the THE MISSION the and IMPOSSIBLE
    Expected Res : MISSION the and IMPOSSIBLE
    Actual Res: mission the impossible

Hi @Balan

check this regex pattern

1 Like

Use this code


StringData=“THE the AND THE MISSION THE IMPOSSIBLE”
StringData=StringData.ToUpper.Substring(StringData.IndexOf(“MISSION”))

Definetly you will get ok it was very simple code use this you will get

regards
Chethan P

@Nived, not yet tried this code. This - MISSION THE IMPOSSIBLE wont be static any words will be there.
Question is any lines starts with
THE
THE THE
AND
AND THE
What ever the no of times or combinations of AND, THE comes it should be removed only should be retained including AND THE

Hi @Balan,

Try this code:
Regex_Remove.xaml (4.6 KB)

Regex:
regex

Thanks!

2 Likes

@Kadiravan its working as expected. Thanks.
@Chetan, @Nived and others thanks as well…

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.