My objective: I wanted to trim down any long URL to the basic domain.
Take something like this:
http://www.ubotstudio.com/forum/index.phpTurn it into this: ubotstudio.com
You should be able to use what I show with ANY type of text string. I created a running demo of the javascript strings to show you HOW they would be used within Ubot.
Download:
Shorten URL.ubot 18.31K
144 downloads
You'll enter a long URL into the UI box above, hit the play button and you'll see the results in the UI stat monitor below. The demo just shows the end result of the variable. You would use this updated variable within your own bots.
Here's everything for pattern matching characters: javascriptkit.com/javatutors/re2.shtml
--- Strip Front Tab -----

The flow is:
'LOOK AT ALL THIS JUNK' .replace /WHATEVER I FIND HERE/ , 'WITH THIS' ;
As a non programer, I was having a hard time figuring out where things started and ended. (/( = is this something? How about this = /, ?
The sections are:
'{1}' = your variable will be inserted here. Just {1} won't work - you need '{1}'
.replace( ); = This is the outside portion of the .replace expression.
/ / = this is an inside group
, = find the stuff to the left of the comma and replace it with what's on the right
( )|( ) = Alterations of groups - (THIS) O|R (THAT) In this instance we're looking either http:// or http://www
'' = empty or nothing. Sometime you WILL have something like '{1}' (a variable)
Notice that there are no slashes here: (http:..www.)|(http:..)
This won't work: (http://www.)|(http://)
Reason: using a / would mean the end of a section. You've got to use a . (dot)
. = match ANY single character
--- Strip End Tab -----

The flow is:
'LOOK AT ALL THIS JUNK' .replace /STARTING FROM THE END AND GOING BACKWARDS, SELECT EVERYTHING AND INCLUDING .COM/ , 'WITH JUST .COM' ;
In reverse order:
$ = start at the end (^ = start at the beginning)
. = ANY single character
+ = match one or more characters
.+. = any character, to any AMOUNT of characters, to any character again. This is the closest you'll come to the standard wildcard (*).
----- Strip both -----
Notice that it strips #URL first and updates #strip, then it strips #strip and updates #URL. By ping pong between variables you can keep updating your original data.
--- Other examples ----
Let's say you wanted just the authors name to a post. The narrowest scape you can do this:
Harry Kabonzi | August 20, 2010
You would run this: '{1}'.replace(/ \x7c.+.$/, '');
The tricky part is the "|" symbol. This won't work: '{1}'.replace(/ |.+.$/, ''); You need to use the hex # for the "|" symbol, which is \x7c. In this case, I'm also adding a blank space before it so I end up with only "Harry Kabonzi". To find more hex #'s, go here.
Again, check out this website for more pattern matching characters: javascriptkit.com/javatutors/re2.shtml













