0

I'm trying to count everything that isn't in tags, but failing.

The sentence: Hi <strong>User</strong> should return the count of Hi User (7)

I tried with

(!?<[^>])^.{1,140}$

but since I'm pretty new to Regex I can't seem to get it right!

0

1 Answer 1

0
<[^>]*>|([^<>])

You can use this and count only the groups captured.That should be your result.See demo.

https://regex101.com/r/uF4oY4/25

5
  • Thank you for your fast reply, but I wonder; How do I, with Regex, count the characters in the groups? As I said, I'm kinda new to the Regex. Aug 14, 2015 at 9:19
  • @user2687506 the no. of groups will be your answer
    – vks
    Aug 14, 2015 at 9:22
  • I guess I can't count the number of groups in Regex? Because I'm not in a programming language, so I can't use anything other than Regex. Aug 14, 2015 at 12:03
  • @user2687506 regex cant return a number based on some calculation.It can only return patterns
    – vks
    Aug 14, 2015 at 12:11
  • Well, I dont need to return a number (I think). ^.{1,140}$ solves the problem with only allowing 140 characters, but I want to exclude the <tags> from the characters I'm "counting" (or what it might be called in regex). Aug 14, 2015 at 13:08

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.