inherit
143665
wildgoosespeeder wildgoosespeeder wildgoosespeeder
0
Jun 14, 2018 5:59:55 GMT -8
wildgoosespeeder
ProBoards V5 be trippin'. I'm disoriented. :P
4,393
August 2009
wildgoosespeeder
|
Post by wildgoosespeeder on Aug 19, 2010 15:20:03 GMT -8
For my Multi-Colored Display Names code, what's the point of "$" for this line? if(a[href].href.match(new RegExp("action=viewprofile&user=" + memberscolors[loop][0] + "$")))
|
|
inherit
23506
0
Nov 19, 2012 5:30:35 GMT -8
James [a_leon]
I feel a strong desire to XSS a cookie from Peter.
4,334
April 2004
mnstrgarge
|
Post by James [a_leon] on Aug 19, 2010 20:44:41 GMT -8
The $ indicates that it's the end of the string.
So let's say you have two members, one with a username of "matt" and one with a username of "matthew". If you didn't have the $ there, and you wanted to give a colored display name to matt, it would also match matthew because "matt" is contained in it.
|
|
inherit
143665
wildgoosespeeder wildgoosespeeder wildgoosespeeder
0
Jun 14, 2018 5:59:55 GMT -8
wildgoosespeeder
ProBoards V5 be trippin'. I'm disoriented. :P
4,393
August 2009
wildgoosespeeder
|
Post by wildgoosespeeder on Aug 19, 2010 20:55:05 GMT -8
So if there is anything else where that $ is, it doesn't count it and makes that expression false?
|
|
inherit
23506
0
Nov 19, 2012 5:30:35 GMT -8
James [a_leon]
I feel a strong desire to XSS a cookie from Peter.
4,334
April 2004
mnstrgarge
|
Post by James [a_leon] on Aug 19, 2010 20:56:28 GMT -8
Correct. If you take it out, then it matches any username that starts with "matt". If you leave it there, it matches only what you've told it to.
One thing you could do, is on a test board, create two users called "user" and "user1". Apply the code to "user", but take out the $, and you should see it affect both accounts. I find actually playing with the modification as opposed to reading about it helps me.
|
|
inherit
143665
wildgoosespeeder wildgoosespeeder wildgoosespeeder
0
Jun 14, 2018 5:59:55 GMT -8
wildgoosespeeder
ProBoards V5 be trippin'. I'm disoriented. :P
4,393
August 2009
wildgoosespeeder
|
Post by wildgoosespeeder on Aug 19, 2010 21:11:59 GMT -8
Does $ work also like:
new RegExp("$" + loop) so if loop = "att" and we have att and matt, it wouldn't work for matt?
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on Aug 20, 2010 2:45:39 GMT -8
Does $ work also like: new RegExp("$" + loop) so if loop = "att" and we have att and matt, it wouldn't work for matt? Nope, you would need a different metacharacter, you will need to use ^ to match the start of the line. I recommend doing what James suggested, create a few users and just modify the expression, that way you will have a much better understanding of them.
|
|
inherit
130228
0
Jul 11, 2024 19:19:59 GMT -8
Charles Stover
1,731
August 2008
gamechief
|
Post by Charles Stover on Aug 20, 2010 4:21:17 GMT -8
$ means the end of the line. ^ means the beginning of the line.
/test/ (contains test) matches test atest testa atesta
/^test/ (starts with test) matches test testa
/test$/ (ends with test) matches test atest
/^test$/ (starts and ends with test) matches test
|
|
inherit
143665
wildgoosespeeder wildgoosespeeder wildgoosespeeder
0
Jun 14, 2018 5:59:55 GMT -8
wildgoosespeeder
ProBoards V5 be trippin'. I'm disoriented. :P
4,393
August 2009
wildgoosespeeder
|
Post by wildgoosespeeder on Aug 20, 2010 10:41:39 GMT -8
/^test$/ (starts and ends with test) matches test OK got all that but wouldn't the thing I quoted be the same thing as "test"? Meaning: word.match(/^test$/) and word == "test" are the same thing?
|
|
Aaron
Junior Member
And what is Fonzie like?
Posts: 265
inherit
25673
0
Mar 10, 2013 19:53:10 GMT -8
Aaron
And what is Fonzie like?
265
June 2004
derfleurer
|
Post by Aaron on Aug 20, 2010 13:35:28 GMT -8
In a conditional, as posted, the two are equivalent, yes. The advantage is brevity.
if(word.match(/^(user|user2|user4|user7)$/)
if(word == "user" || word == "user2" || word == "user4" || word == "user7")
|
|
inherit
23506
0
Nov 19, 2012 5:30:35 GMT -8
James [a_leon]
I feel a strong desire to XSS a cookie from Peter.
4,334
April 2004
mnstrgarge
|
Post by James [a_leon] on Aug 20, 2010 15:42:54 GMT -8
/^test$/ (starts and ends with test) matches test OK got all that but wouldn't the thing I quoted be the same thing as "test"? Meaning: word.match(/^test$/) and word == "test" are the same thing? Yes, but an advantage to using word.match(/^test$/) is that you can add flags to make it so it'll match any casing. So you could match Test, TEST, TeST, etc, instead of just "test". That'd be word.match(/^test$/i) Now, you could match the same using word == "test", but you'd have to do it like this: word.toLowerCase () == "test" I just prefer to use the .match, allows for matching variable strings better. And of course what Aaron said, I just felt that was important enough to note.
|
|
inherit
143665
wildgoosespeeder wildgoosespeeder wildgoosespeeder
0
Jun 14, 2018 5:59:55 GMT -8
wildgoosespeeder
ProBoards V5 be trippin'. I'm disoriented. :P
4,393
August 2009
wildgoosespeeder
|
Post by wildgoosespeeder on Aug 20, 2010 17:33:45 GMT -8
I know what "g" and "i" do. The "g" is for finding all cases where the RegExp is true and "i" means case insensitive. Yup I understand completely! Another question. So if I wanted to search for ^ or $, I'd do /\^/ or /\$/?
|
|
#00AF33
14306
0
1
Sept 8, 2023 8:54:17 GMT -8
Jordan
What is truth?
11,838
October 2003
jab2
|
Post by Jordan on Aug 20, 2010 18:04:30 GMT -8
I know what "g" and "i" do. The "g" is for finding all cases where the RegExp is true and "i" means case insensitive. Yup I understand completely! Another question. So if I wanted to search for ^ or $, I'd do /\^/ or /\$/? Yes, but don't take our word for it, try it yourself.
|
|