SocialsRegex
Social Regex Account Detection and Extraction for Ruby. Detect and extract URLs of social accounts: throw in URLs, get back URLs of social media profiles by type.
Features:
- detect the platform a url points to (all major platforms supported)
- extract the information contained within the url (without opening the url, of course)
- extract emails and phone numbers from hyperlinks
Installation
Install the gem and add to the application's Gemfile by executing:
$ bundle add socials_regex
If bundler is not being used to manage dependencies, install the gem by executing:
$ gem install socials_regex
Requirements
This gem requires Ruby 2.6+
Usage
require 'socials_regex'
supported_platforms = SocialsRegex::Platforms.all
supported_regexes = SocialsRegex::Regexes.all
platform_regexes = SocialsRegex::Socials::PLATFORMS_REGEX
twitter_regex = SocialsRegex::Socials::PLATFORMS_REGEX[:twitter]
text = 'https://twitter.com/karllorey/status/1259924082067374088' \
'https://twitter.com/karllorey12/status/12599240820673740883' \
'http://crunchbase.com/organization/acme-corp jeff@amazon.com mailto:plususer+test@gmail.com' \
'https://facebook.com/peter.parker https://www.facebook.com/profile.php?id=100004123456789' \
'https://github.com/talaatmagdyx https://github.com/talaatmagdyx/socials_regex' \
'https://news.ycombinator.com/item?id=23290375 https://instagram.com/__disco__dude' \
'https://www.linkedin.com/in/talaatmagdyx/ https://medium.com/does-exist/some-post-123abc'
extract = SocialsRegex::Extraction.new(text: text)
extract.extract_matches_per_platform
extract.extract_matches_by_platform(platform: 'instagram')
matches = extract.extract_matches_by_regex(regex: SocialsRegex::Regexes::TWITTER_URL_REGEX[:status])
References
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and the created tag, and push the .gem
file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at Contributing. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
Reporting Bugs / Feature Requests
Please open an Issue on GitHub if you have feedback, new feature requests, or want to report a bug. Thank you!
Pull Request
Please read Contributing
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the SocialsRegex project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.