SPECIFYING THE NUMBER OF IDENTICAL CHARACTERS WHEN SEARCHING A STRING

Hey everyone,
The built-in function indexOf() searches for a character "." in the string "1.2.3." if the value == 1.
It searches nothing if the value == 0 or 2 or any number greater than 2.
var txt:String = "1.2.3.";
var output:String = String(this);
if (txt.indexOf(".") == 1)
trace(output);     //[object MainTimeline]
The must be a simple method for specifying the number of characters "." when searching the string "1.2.3.".
For example if there is 2 characters "." in the string "1.2.", then run through a statement but if it does not contain 2 characters "." then do nothing.
There is a built-in function called contains but it is mainly used in XML.
indexOf() looks like unstable javascript codes, one of those framework that unixers hate.

Why have an alternative when the built-in RegExp class does the job better than anything else?   Is it that you find them too hard to work with?  If you want a one line solution and prefer to use the older built-in methods you can do so by creating your own custom class to do what you want... searching a string character by character for the one you wish to isolate and counting them.
In any case, you have a solution to counting the number of "." characters.
"Many" people say what?  I doubt many people say anything like that at all.

Similar Messages

  • Specify the number of rows in Cursor

    Hi,
    Can anyone tell me, if there is some way where i can specify the number of rows to be fetched in a single cursor.
    As in, The first fetch 100 rows, second 100 and so on
    Regards,
    Rishav

    Hi
    Use the option PACKAGE
    FETCH NEXT CURSOR <CURSOR> INTO TABLE <int table> PACKAGE SIZE 100.
    Max

  • ORA-24333: zero iteration count  Cause: An iteration count of zero was specified for the statement Action: Specify the number of times this statement must be executed

    Get the following error from Oracle 
    ORA-24333: zero iteration count
    Cause: An iteration count of zero was specified for the statement
    Action: Specify the number of times this statement must be executed
    Any suggestions on whether is this a Oracle bug or if not what should be set to avoid this failure.

    Hello get this from executing the following.
    Occurs intermitently.
    select MAX(LENGTH(lxVal)) from lxString_74501fb6 where lxType=910231053
    Find the MaxLenght(LxVal) returned is null for this query.
    Did google it but says the iterator not initialized. But not the case here
    Thanks

  • How can we specify the number of decimals to be printed

    How can we specify the number of decimals to be printed
    such as "%5.2d" in C.
    Can anyone help me

    You could use the DecimalFormat or NumberFormat to do the job.
    double number 1234.567;
    DecimalForamt df = new DecimalFormat("###.##");
    String s = df.format(number);or
    double number 1234.567;
    NumberFormat nf = NumberFormat.getNumberInstance();
    nf.setMaximumFractionDigits(2);
    /* if needed.
       nf.setMaximumIntegerDigits(value);
       nf.setMinimumFractionDigits(value);
       nf.setMinimumIntegerDigits(value); */
    String s = nf.format(number);I didn't test the codes but they should work. For more information, please consult the documentations.

  • How to know the number of times end users search on iStore

    How can we know the number of times end users search on iStore

    I am not sure how can you do that with Oracle but I am doing that with Google Analytics (Site Search Settings).
    Thanks
    Shazi
    Edited by: 903823 on Nov 30, 2012 7:59 AM
    Edited by: 903823 on Nov 30, 2012 7:59 AM

  • Is it possible to reduce the number of HTTP calls when using a ReportViewer control?

    My application is written in .Net 4 using Visual Studio 2010 (version 10 of the ReportViewer control). The report in question contains a lot of data in the dropdowns used for parameter selection. For example, one dropdown contains 95k options and another
    uses 24k options (I know this is bad design, but we need to keep it as-is for this release). When I use Fiddler to profile the report, I see that it makes a lot of HTTP calls and a majority return the same dataset. There are three phases of loading data. Each
    one initiates a series of HTTP calls.
    Loading the initial header with the filter controls (dropdowns, textboxes, etc).
    Changing one of the dropdowns that has a dependent dropdown (start date/end date)
    Loading the final report after clicking the View Report button
    In total, 13 HTTP calls are made and 10 of those are returning the same 10MB of data. The final report only returns 13 records, but the whole process of loading the report filters, changing report filters and loading the report require 130MB of data to be
    exchanged. This is an extreme example, but we do have other reports that are doing the same with smaller amounts of data.
    My question: is there any way to modify the ReportViewer or the SSRS server to reduce the number of calls? Is this related to ViewState? Please understand that I am new to Reporting Services and have a lot to learn.

    Hi rodeofive,
    As per my understanding, the issue is a performance issue. And it is caused by there are thousands of values in the drop-down list of parameters in the report.
    To work around this issue, I suggest you should make some changes in the report. For example, we can add additional two parameters with multiple keywords ahead, one for the dropdown contains 95k options, another for dropdown contains 24k options. Then all
    of available values which are begin with the keywords will display in the parameter list. In this scenario, we can create cascading parameters. One is a keyword parameter, and the other parameter is the drop-down list that based on the keyword to display the
    available values.
    For more details about the method, please refer to the following FAQ:
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/8de6c783-9cb4-4b95-9be8-b59bc0049866/forum-faqhow-do-i-add-a-search-feature-in-the-parameter-with-long-drop-down-list?forum=sqlreportingservices#8de6c783-9cb4-4b95-9be8-b59bc0049866
    Hope this helps.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Specifying the size of a file when creating a new file

    How do I go about doing this? I specifically need to create different file sizes (2mb's all the way up to 10mb). I was poking around through the File class and there doesn't seem to be a way to do this. There is a way to get the size of it in bytes, but no way to create an empty file straight off the bat with the file size specified. Does anyone know how to do this?
    Thanks.

    the reason I want to do this is because I need to pass certain file sizes over a network and see if the system can handle the sizes of the file under load. the files dont necessarily have to be empty, they can be filled with a bunch of jibberish, but I figured it would be easier to be able to just specify the size of the file rather than have a loop that loops and places over 2 million characters into a file. because a 2mb file is going to be the smaller of the files that needs passed through and that will take too long to create.
    and thanks for the link to randomaccessfile. im probably going to use that, just specify the file size and be done with it. unless theres a better way to do it, but i cant find anything.

  • Can you specify the port for default services when installing OEG?

    Hi everyone,
    The default installation of OEG 11g uses 8090 port for management services, and 8080 for the virtualized services that you register in the gateway. After installation, you can change the ports by editing gateway's Profile Repository in Policy Studio. But is there a way to specify the port number before/during the installation?
    Thanks,
    Iris

    Hi -
    here are the steps to change the listening port (in 11.1.1.6)
    - Connect to OEG using Policy Studio
    - Click on "Edit Active Configuration"
    - Under "Services", find the default services, and you'll see a listener for port 8080 there. Right-click to edit this.
    - Change the port from 8080 to your desired port. Note that if you've installed the software and running it as a non-root user on Linux, then it will not have permission to bind to a low-number port (like port 80 for instance)
    - Now deploy your change (for 11.1.1.6 hit F6 or click on the "deploy" button which is towards the right of the toolbar in Policy Studio).
    - You may also choose to version your configuration at this point (click on "version" which is beside the "deploy" button and enter a comment about your version).
    Now verify that OEG is listening on your new port. You can see it bind to the new port by looking at the trace [Connect a browser to port 8090 on OEG, login as admin or another user who has rights to view the trace, then click on "Trace"].
    It's a usual practice to configure a new listener on SSL (e.g. on port 443) then to delete that pre-configured port 8080 listener, if you want to only receive traffic over SSL.

  • How can I specify the number of bins?

    I am using DM4J to create an OCluster model build component and am utilizing the autobinning capability. I would like to specify for each field the number of bins in which I would like the data segmented. How would I go about accomplishing this task?
    Thanks,
    Dianna

    The ability to set specific number of bins or even custom bin definitions for each attribute is only supported through the ODM API at this point.
    Look at the ODM java doc that was installed in your JDev\lib\ext directory and check out the oracle.dmt.odm.transformation package. You can also look at the ODM Sample code which has sample code that creates the binning specification then applies it to data. The sample code is available in the database Oracle Home directory.

  • Field in Material Master to specify the number of Days to keep the stock

    Dear Gurus,
    I want to define in Material Master, that i want to keep the Stock of the Material of 4 days as Safety stock, My consumption of Material can vary from month to month low or high. But i want to keep the number of Days fixed in Material Master for the Safety Stock. So that if my consumption varies, my Stock Quantity for Safety automatically updated.
    Regards,
    Johi Kapoor

    Hi,
    Check the TAB safety time/act. cover {Screen field MARC-SHZET, Field selection group-57} in MRP-2 screen in net requirement calculation segment.
    Regards,
    Biju K

  • What's the best way to do this (searching inside strings)

    Hello. I am trying to do something pretty trivial but the way I've set out to do it seems overly complicated and I bet there's a much easier more efficient way of doing it.
    Basically I want to parse a string which is fairly small in size but contains many line breaks. Take the following text for exemple :
    ====
    Session 4042312
    Room 1 is the active room
    Total number of friends : 2
    Room 1: Bariachi ( away )
    Room 2: Concaveman ( busy )
    ====
    This whole text, in it's above form, is copied into my string. The way I do that is simply copy it and then read it from the clipboard as such :
    public String getClipboard()
      Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
      try
         currentText = (String)c.getContents(this).getTransferData(DataFlavor.stringFlavor);
      catch(Exception e)
      currentText = "empty";
      System.out.print(currentHand);
      return currentText ;
      } once this is done, I want to be able to parse the string in order to retrieve, as in the above exemple, the session number. the number of friends and the names.
    So here what I want to do but I don't know exactly how :
    search for "Session "
    sessionNumber = copydown untill next line break
    search for "friends : "
    noFriends = copydown numerical characters untill you hit a character that's not numerical
    search for "Room %: "
    name1 = copydown untill next space character
    search for next "Room %: "
    name1 = copydown untill next space character
    I don't know wether it's possible to use wildcards (like in "Room %: ") when searching for a substring but I assume it must be, I just don't know how. Is it also possible to tell java to "copy down X following numerical characters and to stop when the next character isn't numerical"
    also when searching for substrings.. does it always start from the top? or can you tell it to just continue on from where it last stopped?

    If this is to submit as homework then the prof. will probably not accept my solution and if he does then you will have to justify the result so ...
    import java.util.regex.*;
    public class Fred800
        public static void main(String[] args)
            try
                String record = "====\n" +
                        "Session 4042312\n" +
                        "Room 1 is the active room\n" +
                        "Total number of friends : 2\n" +
                        "Room 1: Bariachi ( away )\n" +
                        "Room 2: Concaveman ( busy )\n" +
                        "====\n";
                Pattern sessionExtractPattern = Pattern.compile("Session +([^\\s]+)");
                Matcher sessionExtractMatcher = sessionExtractPattern.matcher(record);
                int currentPosition = 0;
                if (sessionExtractMatcher.find(currentPosition))
                    System.out.println("Session\t" + sessionExtractMatcher.group(1));
                    currentPosition = sessionExtractMatcher.end(1);
                Pattern countExtractPattern = Pattern.compile("Total number of friends : +([^\\s]+)");
                Matcher countExtractMatcher = countExtractPattern.matcher(record);
                if (countExtractMatcher.find(currentPosition))
                    System.out.println("Count\t" + countExtractMatcher.group(1));
                    currentPosition = countExtractMatcher.end(1);
                Pattern namesExtractPattern = Pattern.compile("Room +(\\d+): +([^ ]+)");
                Matcher namesExtractMatcher = namesExtractPattern.matcher(record);
                while (namesExtractMatcher.find(currentPosition))
                    System.out.println(namesExtractMatcher.group(2) + "\t" + namesExtractMatcher.group(1));
                    currentPosition = namesExtractMatcher.end(2);
            catch (Exception e)
                e.printStackTrace();
    }

  • Grep Removing Characters when searching for Paragraph returns

    I'm currently working on an xml based business card file and the formatting requires me to search for a phone number followed by a End of Paragraph followed by a Page Break and then remove the unnecessary Paragraph Return. For some reason inDesign will not find an End of Paragraph then a Page Break through the following grep code "\r~P", however if I search for "\r\r" it will find it. I have been able to get this to work with "(\d{3}\.\d{3}.\d{4})\r\r" and then change to "$1~P", but each subsequent business card loses one number off of the end (804.777.7777, 804.777.777, 804.777.77 etc). What would cause this?
    Thank you,
    Brandon Boswell

    You should move this over to scripting (http://forums.adobe.com/community/indesign/indesign_scripting). You'll find people over there who can give you more help, if there is any.

  • How do I change the number of spaces generated when I press the tab key when composing an email message?

    I'm running Thunderbird 24.3.0 on Vista Home Premium.

    issues within issues.
    Short answer is you can not.
    Long answer is see short answer plus tabs are not for "Spaces" they are for measured distances. Modern operating systems use proportional fonts and a W is much wider than an I, whereas a mono spaced font such as IBM Courier uses the same space for both.

  • What function can be used to count the number of cells who have a specific string (i.e. "Blue")?

    I am attempting to gather information as to the makeup of the cars in a parking lot. I have already gathered data as the make, model, and color of the care on each car. How would I go about counting the amount of cells which 'red' or 'honda'?

    Do you know that iWork Formulas and Functions User Guide is not delivered to help users to help you ?
    So, download it and search for the keystring COUNT
    I bet that you will find quickly the functions COUNTIF and COUNTIFS.
    Yvan KOENIG (VALLAURIS, France) mardi 13 septembre 2011 16:29:14
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.0
    My iDisk is : <http://public.me.com/koenigyvan>
    Please : Search for questions similar to your own before submitting them to the community
    When we wish to know, we question. When we want to be capable, we study.

  • What's wrong with the built-in keyboard on my macbook? The caps button does not work rite, no matter what letter button i push they all come out capitals and the number keys when pushed display the special characters instead of the numbers!

    the built-in keyboard on my macbook is not functioning right, the number keys when pushed display the special characters instead of the numbers,
    the caps button doesn't work at all, the letter buttons display capitals when pushed whether the caps button is on or off, the shift keys are also out of whack!!
    It seems it somehow got relocated to the "0" button because if you push and hold the zero button down the keyboard seems to operate normally, the number keys display numbers when pushed the letter keys display lower case when pushed but release the zero button and your back in the twilight zone!! Can anybody help me resolve this issue? one more thing im using an external usb keyboard right now and it seems to function properly if that helps any.

    You would do better in the actual macbook pro forums (this is not).

Maybe you are looking for