0

I am looking for a regex that gives me something of the format:

"Core i7 Extreme Edition" or "Core i3" or "Atom" or "Pentium", given the following inputs:

"Intel® Core™ i7-6950X Processor Extreme Edition", "Intel® Core™ i3-6300T Processor", "Intel® Atom™ Processor D2550 " or "Intel® Pentium® Processor G4400" or "Intel® Core™2 Duo Processor E6400" or "Intel® Core™2 Extreme Processor QX6800" or "Intel® Core™2 Quad Processor Q9400S".

I want to read the special identifying features from the product name.

I realise that something along the lines of this: Core|i3|i5|i7|Atom|Pentium|\s4\s|Celeron|Extreme Edition

Will give me what I want in a perfect world, where nothing is added.

It is possible to create it? If it adds anything I am using C# but it is in an environment that is very generic and I only have the string and the regex.

1 Answer 1

1

You can try this regex: (See on regex101)

Intel® | Processor|®|™|[ -][A-Z]*\d{4}[A-Z]*

And replace with empty string "". This matches all non-wanted parts and removes them.

string pattern = @"Intel® | Processor|®|™|[ -][A-Z]*\d{4}[A-Z]*";
string substitution = @"";
string input = @"Intel® Core™ i7-6950X Processor Extreme Edition";
Regex regex = new Regex(pattern);
string result = regex.Replace(input, substitution);
Sign up to request clarification or add additional context in comments.

4 Comments

Almost works perfectly, but I have one "edge" case where it misses the number "2" after ™ in, "Intel® Core™2 Quad Processor Q9400S".
prntscr.com/dc0w9c from regex101 prntscr.com/dc0wkx from debug example in Visual studio. I must be doing something wrong compared to you then?
Oh you mean you want to keep the number 2?
Yes this is specifically a part of the identifiication of the product. Sorry if it was unclear.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.