Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Regex help....
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Aptmunich" data-source="post: 767173" data-attributes="member: 3850"><p>Hey guys!</p><p></p><p>I'm working on a uni project and am having trouble parsing a string using regex. (this is a Java project)</p><p></p><p>Example:</p><p>"@John23 This is my message".</p><p></p><p>I want to be able to recognize "@John23", so I can route the message only to the user "John23".</p><p></p><p>I can get it working without numerals using this code as the regex input strings:</p><p></p><p>[CODE] </p><p>String re1="(@)"; // PM Identifier</p><p>String re2="((?:[a-z][a-z]+))"; // Username</p><p>String re3="(\\s+)"; // White Space = separator username / message</p><p>[/CODE]</p><p></p><p>But I've been having trouble getting it working with any type of ASCII character as the username. I think it's as simple as extending the "re2" String to include 0-9 etc.</p><p>Or making "re2" accept any characters, except whitespace (I think ".*" would also include whitespace, correct?). </p><p></p><p>Any ideas?</p></blockquote><p></p>
[QUOTE="Aptmunich, post: 767173, member: 3850"] Hey guys! I'm working on a uni project and am having trouble parsing a string using regex. (this is a Java project) Example: "@John23 This is my message". I want to be able to recognize "@John23", so I can route the message only to the user "John23". I can get it working without numerals using this code as the regex input strings: [CODE] String re1="(@)"; // PM Identifier String re2="((?:[a-z][a-z]+))"; // Username String re3="(\\s+)"; // White Space = separator username / message [/CODE] But I've been having trouble getting it working with any type of ASCII character as the username. I think it's as simple as extending the "re2" String to include 0-9 etc. Or making "re2" accept any characters, except whitespace (I think ".*" would also include whitespace, correct?). Any ideas? [/QUOTE]
Verification
Post reply
Forums
macOS & iOS Developer Playground
macOS - Development and Darwin
Regex help....
Top