Share via

Regular expression from several words

diego gutierrez 161 Reputation points
2022-02-14T20:00:58.797+00:00

Hi all.

Please, can you help me to create a regular expression to get a string based on this query

Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.

0 comments No comments

Answer accepted by question author

Viorel 127K Reputation points
2022-02-15T08:25:47.617+00:00

An example:

string input = "Creativity is thinking-up new things. Innovation is doing new things!";
string result = Regex.Replace( input, @"(?<=\G.*\w)(\w*)(?=\w)", m => m.Value.ToLower( ).Distinct( ).Count( ).ToString("0;0;''" ) );

Console.WriteLine( input );
Console.WriteLine( result );

or:

string result = Regex.Replace( input, @"(?<=\G.*\w)(\w+)(?=\w)", m => m.Value.ToLower( ).Distinct( ).Count( ).ToString( ) );

Was this answer helpful?

2 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. GunnerJosh82 1 Reputation point
    2022-02-18T19:09:15.083+00:00

    Hi Viorel-1.
    Can you do the same thing with Python?
    Thanks in advance.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.