Remove spaces at both ends of the string in flex.

Source: Internet
Author: User

Today, I encountered a problem. When I judge two strings, there is always false. Why is this problem obviously true for the same string, then I will write the string to be judged directly after =, for example, "ABC.

If ("ABC" = "ABC ")

No problem, but I began to think about the cause.

Finally, I found it. I stored a field in the database to an arraycollection in the foreground through the background Java.For example, arr. Then, arr. getitemat (10). Str = "ABC ",That's the point of attention.

This string is correct in the database, but it is often followed by some spaces,

The solution is as follows:

Import MX. utils. stringutil;

Then

If ("ABC" = stringutil. Trim (ARR, getitemat (I). Str ))

In this way, it's okay to pass the judgment.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.