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

  • Home
  • SEARCH
  • 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 7943021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:09:00+00:00 2026-06-04T00:09:00+00:00

I have a String, I wish to use Linq to run a regular expression

  • 0

I have a String, I wish to use Linq to run a regular expression to cut down my string to a smaller sub-string which matches my reg ex.

My code at the moment gives the error

‘char’ does not contain a definition for ‘Name’ and no extension
method ‘Name’ accepting a first argument of type ‘char’ could be
found

My code :

string variable = result.Name.Select(r => regEx.Match(r.Name).Groups[2].ToString());

Result.Name is a string contained in a custom class.

What have I done incorrectly? What is wrong with my syntax/understanding ?

  • 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-04T00:09:01+00:00Added an answer on June 4, 2026 at 12:09 am

    You’re calling Select on a single string. Select is treating your string as a series of characters, and so the r in your lambda expression is a char.

    If you only have a single string you want to pass into your regular expression, and you only want a single match out, then you don’t need LINQ at all. Just call

    string variable = regEx.Match(result.Name).Groups[2].ToString();
    

    (I’m assuming result.Name is your single string, based on your example code.)

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

Sidebar

Related Questions

I have an xml string that I wish to traverse using LINQ to XML
I have a std::vector<std::string> temp_results and I wish to use std::for_each to go through
hey I have a string as such: 357902||190||RUE RACHELLE||ST|||LES CÈDRES|J7T1J9|QC I wish to take
I have used the String Tokenizer in Java. I wish to know if there
I have a string of numbers in C++: like string str=1234567012 I wish to
Basically, I have a JTextPane to hold some text which I wish to style.
I wish to use $(member.email) , a variable which I've passed into a JSP
I have a string containing the class name and I wish to get a
I have a simple C# function I wish to use from VBA. For the
I have a string in the following format 'DOMAIN\username'. I wish to trim the

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.