Comments on: Code: Regex for Instagram Username and Hashtags https://blog.jstassen.com/2016/03/code-regex-for-instagram-username-and-hashtags/ A place for collecting my miscellaneous thoughts. Tue, 07 Dec 2021 07:01:10 +0000 hourly 1 https://wordpress.org/?v=7.0.7 By: TheBox193 https://blog.jstassen.com/2016/03/code-regex-for-instagram-username-and-hashtags/#comment-93 Fri, 04 Aug 2017 03:30:00 +0000 http://blog.jstassen.com/?p=716#comment-93 In reply to Carlos Pinto.

Ah you’re right! It’s the same rules I believe, I’ve just use the same regex but swap the @ for the #. Or you can combine them like you say. Nice catch!

]]>
By: Carlos Pinto https://blog.jstassen.com/2016/03/code-regex-for-instagram-username-and-hashtags/#comment-92 Wed, 02 Aug 2017 15:17:00 +0000 http://blog.jstassen.com/?p=716#comment-92 Hi thanks for providing this. It works well for usernames, but the title is misleading since it doesn’t cover hashtags. You need the or operator in the first segment of the regex: (?:@|#) so that it includes the @ and the #.

]]>
By: Regular Expressions | New Life https://blog.jstassen.com/2016/03/code-regex-for-instagram-username-and-hashtags/#comment-91 Thu, 19 Jan 2017 07:19:13 +0000 http://blog.jstassen.com/?p=716#comment-91 […] Instagram handle ([A-Za-z0-9_](?:(?:[A-Za-z0-9_]|(?:.(?!.))){0,28}(?:[A-Za-z0-9_]))?) from jstassen […]

]]>
By: TheBox193 https://blog.jstassen.com/2016/03/code-regex-for-instagram-username-and-hashtags/#comment-90 Wed, 26 Oct 2016 13:45:00 +0000 http://blog.jstassen.com/?p=716#comment-90 In reply to Geo.

@disqus_gm92v83kAy:disqus You should be able to just take off the first section of the regex (?:^|[^w])(?:@).

If you’re parsing text you’re going to need to loop over your text looking for all matches, added them to an array.

Here is an example: http://jsbin.com/rajazurofu/edit?js,console

]]>
By: Geo https://blog.jstassen.com/2016/03/code-regex-for-instagram-username-and-hashtags/#comment-89 Wed, 26 Oct 2016 06:14:00 +0000 http://blog.jstassen.com/?p=716#comment-89 @JStassen, thank you for sharing this. How would you modify if you were to do it without the ‘@’? Infact, if we had to check to make sure that no one had entered the @ to say storing it in the database?

]]>
By: Akbar Amani https://blog.jstassen.com/2016/03/code-regex-for-instagram-username-and-hashtags/#comment-88 Sat, 09 Jul 2016 06:16:00 +0000 http://blog.jstassen.com/?p=716#comment-88 Thank you so much, This is the best regular expression for Instagram username

]]>