Question: I'm trying to integrate one function into another function and am puzzled.

What I'm trying to do is add a jQuery function that will call a random quote, and I want that function to fire on a tab change in jQuery Tabs UI.

This is the random quote function:

```
$.get('quotes.txt', function(data) {
        var quotes = data.split("\@");
        var idx = Math.floor(quotes.length * Math.random());
        $('.quotes').html(quotes[idx]);
    });

```

And below this is the tabs init (along with another function that collapses divs when a tab is changed):

```
$(document).ready(function() { 
    var $tabs= $("#tabs").tabs({
        fx : { 
            opacity: 'toggle' 
        },
        select : function(event, ui) {
            $(".entry-content").hide();                
        }                  //I assume it goes near here, but no luck
    }); 
});

```

Does the quotes function need to have the variables called first?

And, how would it work to make the quote div also use the fx opacity effect when it changes quotes?

**Edit 4/27/11**

This works and uses the fx effect in the function:

```
$(document).ready(function () {
    var $tabs = $("#tabs").tabs({

        fx: {
            opacity: 'toggle'
        },

        select: function (event, ui) {
            $(".entry-content").hide();

            $('div#quotescontainer').load('quotes.html', function () {
                var $quotes = $(this).find('div.quote');
                var n = $quotes.length;
                var random = Math.floor(Math.random() * n);
                $quotes.hide().eq(random).fadeIn();
            });
        }
    });
});

```

Answer: 
```
 <replaceregexp file="file.txt" match="[^ ]*/" replace="" byline="true" flags="g"/>

```
Ant isn't well suited for tasks like this. It's probably much more simple to write a simple Ant Task in Java for that (or a small Java program; just create `File` objects and invoke `getName()` to get the last path element).

But if you have to: [`script`](http://ant.apache.org/manual/Tasks/script.html) and [`scriptdef`](http://ant.apache.org/manual/Tasks/scriptdef.html) are probably your friends (provided that your version of Ant is recent enough; the docs mention 1.6.3). You can call any Java method from these scripts. See the [manual](http://ant.apache.org/manual/tasklist.html) for examples.