user3872094
user3872094

Reputation: 3351

Regex match tag with no spaces

I've the below html tags.

<item id="ID1" num="num1">
<item id="ID1">

I want a regex to match <item id="ID1"> and ignore <item id="ID1" num="num1">.

please let me know how can i do this.

Thanks

Upvotes: 0

Views: 41

Answers (4)

vks
vks

Reputation: 67968

/<item id=".*?"\s*>

You can try this.

Upvotes: 1

SMA
SMA

Reputation: 37033

Try:

<item id=\"[^ ]*\">

Upvotes: 1

static_void_meringue
static_void_meringue

Reputation: 126

You can use \S+ to match any non-space characters.

<item id=\S+>

Upvotes: 1

Toto
Toto

Reputation: 91448

I'd use:

/<item id="[^"]+">

Upvotes: 1

Related Questions