0

I have the following piece of coding which is used to grab a username inside of a textarea to make later use of the variable.

var username = $('#c_post-text').val().split(/(\[call\]|\[CALL\])/gi)[2].split(/(\[\/call\]|\[\/CALL\])/gi)[0];

Is there a way to iterate this piece of code so it can be used on multiple instances of the same BBCode, thus grabbing multiple usernames instead of the very first username that is found between the 'call' BBCode tags?

The following will turn all instances of the BBCode into an array, but I only need the username and the array returns the BBCode as well.

var username = $('#c_post-text').val().match(/(\[call\]|\[CALL\])(.+?)(\[\/call\]|\[\/CALL\])/gi);

I am using the ZetaBoards forum software platform and here is the source code: http://b2.ifrm.com/63/1/0/p474641/Mention_Notifications.js

  • Can you show some example input, and the required/expected output? You also need to show your [mcve] code, so we can see what you're doing, help you sorority and, perhaps, suggest other improvements to your code. It's also worth taking a read of the [ask] guidelines. – David Thomas Mar 03 '17 at 16:47
  • Possible duplicate of [How do I retrieve all matches for a regular expression in JavaScript?](http://stackoverflow.com/questions/6323417/how-do-i-retrieve-all-matches-for-a-regular-expression-in-javascript) – Andreas Mar 03 '17 at 17:09
  • I have edited the OP to add the applicable source code, which will provide the input and output in the source itself. I believe the code given will provide the 'Minimal, Complete, and Verifiable example' as it's basically just a code that needs to work in a textarea, but multiple times for each BBCode text entry. I believe the link @Andreas provided is actually what I need, I'm just confused on how to use it in the way I'm needing to. Sorry for any mishaps, I'm not very familiar with asking questions here. – Cory Roberts Mar 10 '17 at 03:22

0 Answers0