https://github.com/harshdoesdev/extractmentions
Extract @mentions from a given string
https://github.com/harshdoesdev/extractmentions
Last synced: 4 days ago
JSON representation
Extract @mentions from a given string
- Host: GitHub
- URL: https://github.com/harshdoesdev/extractmentions
- Owner: harshdoesdev
- License: gpl-3.0
- Created: 2020-07-17T07:12:35.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-17T07:46:30.000Z (almost 6 years ago)
- Last Synced: 2025-10-29T04:28:37.233Z (9 months ago)
- Language: JavaScript
- Size: 20.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# extractMentions
Extract @mentions from a given string
This lib does not uses regex. it automatically handles punctuation marks like "." and "," etc.
```javascript
const extractMentions = require('/path/to/extractMentions.js');
let str = `
hello @name, welcome to @delhi!
`;
console.log(extractMentions(str)); // returns [{name: "name", index: 6}, {name: "delhi", index: 24}]
```