Split a string by word

Hi Team,

Can we split a string by word or sentence

Example-

This is exception block

This id dev block

This is second exception block

Output

This is dev block

Hi @Hitesh1 ,

I’m not entirely sure if this is what you meant, but instead of splitting, you can retrieve all the text present in the middle using this snippet of code →

image

System.Text.RegularExpressions.Regex.Match(yourVariable,"(?<=\r?\n\b)(.*?)(?=\b\r?\n)").Value

Would that help?

Kind Regards,
Ashwin A.K

1 Like

My actual string looks like this, where I need only body section details

<?xml version='1.0' encoding='UTF-8'?>

<env:Envelope xmlns:env=“abcd…”>

   < env :Body>

    <check>check ..</check>
    <check1>check1 ..</check1>

</env:Body>

Thankyou , It got solved

Hi @Hitesh1 ,

Glad I could be of help, I’d appreciate it if you would mark the answer as solution so that others facing similar queries can benefit from it, also so as to close this thread.

If there is anything additional, please include it here so that anyone else who visits this thread may find it useful.

Kind Regards,
Ashwin A.K

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