PDA

View Full Version : Regular Expressions in JavaScript



ReadyToLearn
05-07-2009, 02:39 AM
Hello,

I'm horrible with regular expressions as was hoping that someone would be able to help me create the RegEx pattern I need to accomplish some basic data extraction.

I have a url in following format:


http://www.example.com/xxx/yyy/index.php?/zzz/aaa/###

I just need the last number (highlighted above). The number itself can be any number of digits long and it's always preceded by a backslash.

Does anyone know a right RegEx pattern to accomplish what I want?

Nile
05-07-2009, 02:54 AM
Here:

<script type="text/javascript">
var site = "http://www.example.com/xxx/yyy/index.php?/zzz/aaa/###";


var site_arr = site.split("/");
alert(site_arr[site_arr.length-1]);
</script>