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 8283163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T10:38:27+00:00 2026-06-08T10:38:27+00:00

In Java I could simply extracts parts of codes or texts using Regex, but

  • 0

In Java I could simply extracts parts of codes or texts using Regex, but in C# I’m not sure how I could do this.
For example:

Pattern p = Pattern.compile("(.*?)b(.*?)d(.*?)", Pattern.DOTALL|Pattern.MULTILINE);
Matcher matcher = p.matcher("abcde");
System.out.println(matcher.group(1));   //c 

I’ve found lots of tutorials about Regex in C# but I found no way to do something simple like this. But it has to work with every kind and number of text, numbers, symbols and so on, so that I can use it for example to extract parts of HTML code.

  • 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-06-08T10:38:30+00:00Added an answer on June 8, 2026 at 10:38 am

    First of all. Your code in java does not work as is.

    Correct code (tested):

    Pattern p = Pattern.compile("(.*?)b(.*?)d(.*?)", Pattern.DOTALL|Pattern.MULTILINE);
    Matcher matcher = p.matcher("abcde");
    if (matcher.find())  // Without this test: [Exception in thread "main" java.lang.IllegalStateException: No match found]
      System.out.println(matcher.group(2));   //c     <--2 instead of 1 
    

    Equivalent in C # (tested):

    Regex r = new Regex("(.*?)b(.*?)d(.*?)", RegexOptions.Singleline | RegexOptions.Multiline);
    Match matcher = r.Match("abcde");
    Console.WriteLine(matcher.Groups[2]);   //c 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to translate the below C# codes into Java, however, I could not
Could anyone give an example program that explains Java Threads in a simple way?
java.lang.IllegalStateException: Could not execute method of the activity . I am new to Android.
The error as shown on the Noir error page: java.io.FileNotFoundException: Could not locate boundaries/lat_long__init.class
I could see bunch of java parsers like OpenCSV, antlr, jsapar etc, but I
I basically want to do a complement set operation in SQLite but not sure
In c++, one could simply do something like this: struct GraphObject { Color color;
I want to implement a method in java that could be used to categorize
Is it possible that adding more import statements to your java code could slow
Does anyone knows a java library that could easily encode java Maps into json

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.