Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5948185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:04:18+00:00 2026-05-22T17:04:18+00:00

Here is the input to my function <div class=\xbox\>TESTING<span class=\newbox\><a href=\javascript:void(0);\ id=\btnbox\>Use a new

  • 0

Here is the input to my function

"<div class=\"xbox\">TESTING<span class=\"newbox\"><a href=\"javascript:void(0);\" id=\"btnbox\">Use a new box</a></span></div><div class=\"cardnumber\">***-1111</div></div>"

When I do the below it never returns anything but -1

input.indexOf("cardnumber")

Any reason this isn’t working? when I do an indexOf(“div”) it returns fine … (help)

thanks guys (sorry for not posting the unit test earlier)

public Cart viewCart() {
        ResponseAndCookies result = service.makeHttpRequestWithUrl("https://www.xbox.com/account/fakebox/");
        String response = result.getResponse();

        String availableCreditCard = "<div class=\"cardnumber\">***";
        if (response.contains(availableCreditCard)) {
            return parseJson.parseCartAndReturnObject(response);
        }

        return null;
    }

    public class XboxViewCartServiceTest {
    @Test
    public void verify_cart_works_with_valid_login() {
        FakeXboxCartParseJson jsonParser = new FakeXboxCartParseJson();
        XboxViewCartService sut = new XboxViewCartService(new FakeXboxViewCartHttpBase(), jsonParser);
        Cart cart = sut.viewCart(null);

        Assert.assertTrue(jsonParser.calledMethod);
    }

    class FakeXboxViewCartHttpBase extends XboxHttpService {
        @Override
        public ResponseAndCookies doHttpPostWithUrl(String url, ResponseAndCookies responseAndCookies, String json) {
            ResponseAndCookies result = new ResponseAndCookies();
            result.setResponse("<div class=\"xbox\">TESTING<span class=\"newbox\"><a href=\"javascript:void(0);\" id=\"btnbox\">Use a new box</a></span></div><div class=\"cardnumber\">***-1111</div></div>");

            return result;
        }
    }

    class FakeXboxCartParseJson extends XboxCartParseJson {
        public boolean calledMethod = false;
        @Override
        public Cart parseCartAndReturnObject(String html) {
            calledMethod = true;
            return null;
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:04:18+00:00Added an answer on May 22, 2026 at 5:04 pm

    This obviously works as you provide it, so there are only 3 options:

    1. There are some non-printable characters in the string;
    2. There is an encoding issue when you read the input and compare;
    3. There’s something wrong somewhere else that we cannot see because you don’t give enough code.

    For the moment, the best best is item 3.

    Please provide more code.

    EDIT (2011-05-23 02:20):

    Thanks for the update to your question. So, now we still cannot be sure as we’re missing the data returned by your endpoint, but there’s a good chance if just doesn’t exactly contain <div class="cardnumber">***.

    Do make sure as well that you specify the right headers for your request and that you use valid content type and character encoding. Please make also sure that you are not using a strange encoding on your source files, as you might be inputting non-standard * characters without knowing it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Element Like <div class=control> <label>&nbsp;</label> <input type=checkbox id=1><span class=controlText>Check Box</span> <div
Here is my HTML code <span class=xxt style=>Hide Me</span> <div><br/></div> <div></div> <span style=> <table>
I want add a unique class for each new div after input, how is
Here is the input form code <tr valign=top> <td align=right class=innertablestyle><font class=normal><strong>Homepage</strong></font></td> <td>&nbsp;</td> <td>
here is link to an example: http://techchorus.net/demos/jquery/hiding-input-elements-in-a-div.html It actally disables few elements on click
I am trying to add 1 to any newly appended id/class: jQuery: $(function(){ $(#add-new-student).click(function()
I have the following html code: <div class=result hide id=userNameTooShort><span class=error>Your username needs to
I have a problem with this function: $(#contentdiv).click(function() { $(this).append(<div class='editable'>For some reason this
I habe read here about defining method for a Javascript class Advantages of using
Here is my helper class class Zend_View_Helper_CommonArea extends Zend_View_Helper_Abstract { public function commonArea() {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.