开发者

Flex - search for string in TextArea

I have a TextArea that allows user input. I also have TextInput that the user can type a string into and I want to be able to search through the TextArea for the string in the TextInput. I've never done anything like this before, searching for strings, so I don'开发者_运维知识库t know which functions to use or how to go about it.

Could someone please explain how to do this, or even give a small code snippet showing the process involved. Thanks.

EDIT:

protected function searchBtn_clickHandler(event:MouseEvent):void
            {
                text = mainTextField.text;
                search_Str = searchTxt.text;

                var search_result:int = text.search(search_Str);
                trace(search_result);
            }


First retrieve the texts from the text area and input field, for example:

var text       = $('#textarea_id').val();
var search_str = $('#input_id').val();

And then we'll do the seach:

var search_result = text.search(search_str);

Now search_result has the beginning index of the search_str in the text, or -1 if the search_str wasn't found.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜