Find words between two words

Hi Team

I need to find words between two words. PFB the paragraph.
“Market Announcement
20 November 2019 Market Announcement 1/1
ASX Limited ASX Customer Service Centre 131 279 | asx.com.au
Description
The securities of Veris Limited (‘VRS’) will be placed in trading halt at the request of VRS, pending it releasing an
announcement. Unless ASX decides otherwise, the securities will remain in trading halt until the earlier of the
commencement of normal trading on Friday, 22 November 2019 or when the announcement is released to the
market.
Issued by
Sandra Wutete
Senior Adviser, Listings Compliance (Perth)”

I need to find words between “Description” and “Issued by”. This two words are always constant.

2 Likes

hi @sshitol

find the below regEx, it will help you to get the text between “Description” and “Issued by”

RegEx : (?<=(Description))[A-Za-z0-9\n\s\t]*(?=(Issued by))

Regarads
Ajay

I tried but its not working

Hi @Ajju,

(?<=Description)([\S\s]*)(?=Issued by)

Try this.

System.Text.RegularExpressions.Regex.Match(strInput,"(?<=Description)([\S\s]*)(?=Issued by)").Value.Trim

regexBetweenLabel.xaml (5.9 KB)

Thanks!

@sshitol

Check with this xaml, you need to pass this paragraph and the input from string and to string. you will get output string between those two strings/words.
StringBetween2Words.xaml (5.4 KB)

@sshitol
Refer this post to extract words between two known words.

Try to use split functionality with multiple delimiters

Hello @sshitol

the reason this code is not working is there are characters/words at every new line

So try this pattern
(?<=Description)([^\n]*\n+)+(?=Issued by)
and let me know if it works or not

Its working fine. Is it possible to remove spaces come between sentences.
Output is coming like this.
"The securities of Millennium Minerals Limited (‘MOY’) will be suspended from quotation immediately under

Listing Rule 17.2, at the request of MOY, pending the release of an announcement regarding an operational

update."

Can we remove those extra spaces and get that output in single line

@sshitol,

Try with this line of code to remove extra spaces from your string, make sure there is no newline character, if newline characters are then we need to remove those as well.

Regex.Replace(yourOutputString, "\s+", " ")

Hello @sshitol
use the above code suggested by @sarathi125

if it doesnt work or if there are new lines which are not getting replaced just replace "\s+" from the code posted above with "\s+|\n+" and it’ll work.

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