JITU99
(jitendra)
May 26, 2023, 1:01am
1
Hi all,
The (successful) football (club(s)) (managers)
I have an array out of above sentence.the array is basically splitting above words.
ArrOfWords = {“the”,”Successful”,”football”,”club”,”s”,”managers”}
Out of the above array I have generated a set of combinations as below.
Combinations array
1.the football club
2.the successful football club s
3.the football s
4.The football s manager
5.football club s manager
Result array.
1.football
2.the successful football clubs
3.the football
4.the football manager
5.football clubs manager
From the first array I know the word before letter “s” is club .
So I have to check in the combinations array
If Letter “s”is present in combination and the word before it is club.
Then I have to remove space between them.
But if letter is ‘s’ and the before word is something else then I have to delete word in that sentence.
The final output is resultsarray
Can someone help with the query please
JITU99
(jitendra)
May 26, 2023, 1:24am
2
@ppr @Yoichi Hi guys good morning can you please help out here.thanks in advance
Yoichi
(Yoichi)
May 26, 2023, 2:55am
3
Hi,
How about the following?
arrRes = arrRes.Select(Function(s) System.Text.RegularExpressions.Regex.Replace(s,"(?<=\bclub) (?=s\b)| s\b","")).ToArray
Regards,
JITU99
(jitendra)
May 26, 2023, 2:58am
4
Hi @Yoichi
Here the club and s are common but they might get changed to some other words.
Can we do something to pass both club and s in variable to the above expression please.
Which would make dynamic to use it for any combinations at runtime.
Yoichi
(Yoichi)
May 26, 2023, 3:02am
5
Hi,
How about the following?
keywords = {"club","apple"}
then
arrRes = arrRes.Select(Function(s) System.Text.RegularExpressions.Regex.Replace(s,"(?<=\b("+String.Join("|",keywords)+")) (?=s\b)| s\b","")).ToArray
The above assumes keywords don’t include special character of regex.
Regards,
JITU99
(jitendra)
May 26, 2023, 3:47am
6
Sorry @Yoichi i might have confused you.
For the first expression you have given.
Stringvar1 will be club
Stringvar2. Will be s
So in the first expression you gave I need to pass stringvar1 and stringvar2 in its respective places .
I hope now my question is clear.
Yoichi
(Yoichi)
May 26, 2023, 4:03am
7
All right. Can you try the following expression?
arrRes.Select(Function(s) System.Text.RegularExpressions.Regex.Replace(s,"(?<=\b"+Stringvar1+") (?="+Stringvar2+"\b)| "+Stringvar2+"\b","")).ToArray
Regards,
1 Like
JITU99
(jitendra)
May 26, 2023, 8:02am
8
Hi @Yoichi Sorry for the delay this works thank you <3
1 Like
system
(system)
Closed
May 29, 2023, 8:02am
9
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.