Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 744927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T09:02:06+00:00 2026-05-14T09:02:06+00:00

I am not very good at regular expression but want to do some thing

  • 0

I am not very good at regular expression but want to do some thing like this :

string=”c test123 d split”

I want to split the word based on “c” and “d”. this can be any word which i already have. The string will be given by the user. i want “test123” and “split” as my output. and there can be any number of words i.e “c test123 d split e new” etc. c d e i have already with me. I want just the next word after that word i.e after c i have test123 and after d i have split and after e i have new so i need test123 and split and new. how can I do this??? And one more thing I will pass just c first than d and than e. not together all of them. I tried

string strSearchWord=”c “;
Regex testRegex1 = new
Regex(strSearchWord);
List lstValues =
testRegex1.Split(“c test123 d
split”).ToList();

But it’s working only for last character i.e for d it’s giving the last word but for c it includes test123 d split.

How shall I do this???

The input might be

string strSearchWord=”c mytest1 d newtest1 e lasttest1″;
split should be based on characters “c d and e”. I will pass them one by one.

or

string strSearchword=”q 100 p 200 t 2000″;
split should be based on characters “q p and t”. I will pass them one by one.

or
string strSearchWord=”t 100 r pass”;
split should be based on characters “t r”. I will pass them one by one.

or

string strSeaRCHwORD=”fi 100 se 2000 td 500 ft 200 fv 6000 lt thanks “;
split should be based on characters “fi,se,td,ft,fv and lt”. I will pass them one by one.

Hope it’s clear. Any other specification????

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T09:02:07+00:00Added an answer on May 14, 2026 at 9:02 am
    string[] splitArray = null;
    splitArray = Regex.Split(subjectString, @"\s*\b(c|d)\b\s*");
    

    will split the string along the “words” c or d, whether or not they are surrounded by whitespace, but only if they occur as entire words (therefore the \b word boundary anchors).

    This gives you all the substrings between your words as an array.

    If you want to loop through the string manually, picking out each word after the search words one by one, you could use positive lookbehind:

    string resultString = null;
    resultString = Regex.Match(subjectString, @"(?<=\bc\b\s*)\w+").Value;
    

    will find the word after c. Do the same for d ((?<=\bd\b\s*)\w+) etc.

    This regex means:

    (?<=\bc\b\s*): Assert that it is possible to match the “complete word” c, optionally followed by space characters, to the left of the current position in the string (positive lookbehind).

    \w+: Then match any alphanumeric characters (including _) that follow.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am not very good with regular expression. I have a string like: var
Can anyone please help me with this...I'm not very good with regular expressions and
Hi I have some experience with programming but I'm not very good with pointers.
I'm doing a multiplatform thing, but I'm not very good with OOP. Currently my
I'm not very good with regular expressions but in Textmate, I'm trying to clear
I found this very handy regular expression on regexlib.com, but i'm at a loss
I'm not very good at PHP and would like to have a PHP function
I'm not very good at regex but maybe there's a simple way to achieve
So I'm stuck. I'm not very good with mod_rewrite or regular expressions in general,
I'm not very good at regular expressions at all. I've been using a lot

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.