Dill Gates
Dill Gates

Reputation: 119

Regex match failing to find text between two characters

I am trying to grab all text from Features<br> to Specification<br> from whole html node. I already tried Regex match like bellow but it returns me nothing. Why is it failing - any idea?

C#

string wholeString = "html text goes here";
string onlyFeatures = Regex.Match(wholeString, @"Features<br>(.*)Specification<br>").Groups[1].Value;

onlyFeatures variable returns nothing

Html:

Universal Table/PC Holder can securely mount your tablet and larger phone to a selfie stick or any tripod with 1/4" thread, which allowing you to record video and taking photos with your Pad and larger phone. Just enjoy the fun with your family and friends.<br>
<br>
Table/PCFeatures:<br>
Mount your Apple iPad on the holder<br>
Female screw adapter, fit for most tripod install.<br>
Polycarbonate material enhanced durability for tripod adapter<br>
Perfect for sharp image shooting, video recording, film watching<br>
Pad Holder width:12.5cm/4.73" to 20.5cm/7.87", fitting any 7" to 9" diagonal screen size tablet<br>
Support iPad mini in both portrait &amp; landscape orientation, iPad 2/3/4/Air/Air2 in landscape orientation, other tablets and Galaxy Tab 7.0 series in portrait orientation<br>
<br>
General Description<br>
100% brand new and high quality<br>
Supports digital camera, card camera and smart phone,Table/PC<br>
Whether you are a Novice or Professional photographer, you will need a steady and robust tripod for many of those wonderful photos. This Traveler Tripod with pan head design is the best choice for outdoor photograph activities. With built-in bubble level, making your tripod perfectly leveled. With non-slip rubber feet , it is ensuring single adjust of each leg, giving a more convenient leg handling.<br>
It has 4 section legs and it's very light and convenient.<br>
It is designed for part time photograph lovers. Help them take high quality scene or group photos without motion and long time human hand holding.<br>
<br>
Features<br>
Premium quality durable product<br>
Portable and flexible, ideal for outdoor, travel and timer shoots<br>
Built-in bubble level, making your tripod perfectly leveled<br>
Easy to set up and store (Just needs a few seconds)<br>
Compatible with all Kinds of Digital Cameras and Camcorder Weights Below 2.5KG<br>
360° horizontal and 90° vertical swivel with 3-way head<br>
With grip for adjusting head position<br>
Solid Safety 4 Section Aluminum Legs with non-slip rubber feet<br>
<br>
Specification<br>
Dimension<br>
Maximum Height: 1060mm<br>
Minimum Height: 350mm<br>
Folded Length: 355mm<br>
Max. Tube diameter: 16.8mm<br>
Maximum Tripod Load:2.5kg<br>
Head type:360° swivel fluid head<br>
Material:1/4 aluminum<br>
Screw Size:1/4"<br>

Upvotes: 2

Views: 53

Answers (2)

Mario
Mario

Reputation: 413

The . matches all characters except line breaks \n

You can specify RegexOptions.SingleLine to change this:

onlyFeatures = Regex.Match(wholeString, @"Features<br>(.*)Specification<br>", RegexOptions.SingleLine).Groups[1].Value;

Upvotes: 0

Sam Tigle
Sam Tigle

Reputation: 403

Its because

(.*)

doenst match line breaks. Use

Regex.Match(wholeString, @"Features<br>([.\s\S]*)Specification<br>").Groups[1].Value;

instead

Upvotes: 3

Related Questions