Finding characters in a line

Hi,
Can any body give me an idea on how to find out wether the given sequence of characters are there or not in a line of text.
Thanks in advance

Also String.contains()
Both allow some -but different - flexibility in how they are used.

Similar Messages

  • How do you find the number of lines in a file?

    I need to count how many lines there are in a file, I am using a BufferedReader to read in the data, but how can I find the number of lines?
    Thanks

    That depends. How do you define a line? Is it a specific number of
    characters, a String that's terminated by a newline character or some
    combination thereof?

  • Dropping characters in text lines (FM8)

    I'm experiencing problems with dropped characters in text lines. Also, I've noticed the history doesn't seem to log all changes made to text lines. The problem can be duplicated as follows:
    1. Open a new portrait blank document and add an anchored frame. (recorded in history)
    2. Add a text line inside the anchored frame from the Tools Palette. In the text line, type "1234" (recorded in history).
    3. Save the file. (history cleared)
    4. Click the cursor after the "4" in the text line and hit a carriage return to create a new text line. (not recorded in history)
    5. In the new text line, type "1234567890"(not recorded in history)
    6. Save the file.
    7. Refresh the screen (cntl l) and the second text line now reads "12346890" (dropped the 5 and 7). Printing the file in steps 5 and 6 also show the 5 and 7 are missing.
    8. Add a new text line inside the anchored frame from the Tools Palette. In the text line, type "12345" (recorded in history).
    9. Save the file. (history cleared)
    10. Click the cursor after the "5" in the text line from step 8 and hit a carriage return to create a new text line. (not recorded in history)
    11. In the new text line, type "1234567890"(not recorded in history)
    12. Save the file.
    13. Refresh the screen and the second text line now reads "12345790" (dropped the 6 and 8).
    Has anyone else seen this problem (or can duplicate it)?
    Also, can someone explain why some of the steps above are not recorded in the history.
    FYI, while trying to find a repeatable sequence to demonstrate this problem, Frame crashed on me.
    I'm running a trial version of Frame 8, version 8.0p273, with XP Pro, on a fairly new Dell Optiplex 740.
    Thanks,
    Jeff Schweiner

    Hi Jeff,
    I have now tried what you're doing and get the same result!
    I have also added a text line with characters a to z. After saving ad doing a ctrl-l, the character after the last one, and the character second after that, in the previous line, was removed. (I first typed "abcd", saved, made a new line, typed "abcdefghi", saved, made ctrl-l, the characters "e" and "g" were removed).
    I have the same version of FrameMaker + SGML, but this is a licensed version, running on Win 2000.
    Regards
    Mikael Sten

  • Printing specific characters of a line of text

    Does anyone know of a good way to extract certain characters from a line of text. Such as printing the first two characters or characters 3 and 4 or characters 7-13 etc. It seems like sed should be able to do this, but I can't find any examples online.
    Thanks!

    This command will extract the last 3 characters from every line:
    sed 's|^.*\(...\)$|\1|'
    Middle characters are a little harder. This command extracts the 23rd, 24th, and 25th characters from every line:
    sed 's|^.\{22\}\(...\).*|\1|'
    But if you are doing columnwise operations, a better tool is awk and not sed.

  • Printing the First 14 Characters of Every Line in a Text File

    My text file looks like the following:
    1111097116274, H0101C58F8110C005, 1, 16:48:03
    1111097116274, H0100058F8110C006, 2, 16:48:10
    1111097116274, H00F0458F8110C006, 3, 16:48:12I want my java program to print the first 14 characters of every line. Here's what I have:
    import java.awt.*;
    import javax.swing.JOptionPane;
    import java.io.*;
    public class Read {
         public static void main( String args[] ) {
        try {
            BufferedReader in = new BufferedReader(new FileReader("aFile.txt"));
            String line;;
            /*String tagid;*/
            while ((line = in.readLine()) != null) {
                 char[] tagid = line.toCharArray();
                 line.getChars(0, 14, tagid, 0); 
                 System.out.println(tagid);
            in.close();
        } catch (IOException e) {
             JOptionPane.showMessageDialog( null, "Error" );
             System.exit(0);
         Instead of printing the first 14 characters of every line to output, it prints the whole text file.
    Any ideas of what's wrong?
    Thanks.

    Well, that's the thing with a highly tuned, precision engine like your mind, JosAH. Adding a little alchohol to the fuel mix provides a performance boost, but as the alcohol/fuel ration increases, the performance improvement peaks and then degrades, until the performance is actually reduced. Now, I understand that in the case of the magic Grolsch, this performance curve is shifted farther to the right (graphed with Grolsch count as the independent variable, and performance improvement as the dependent variable), but it still occurs.
    I recommend nitrous oxide. You may need to get your piston heads hardened, though.
    � {�                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Please Help!!   (Stripping first 7 Characters of every line in a file???

    Hey guys,
    I need to read in a file but strip the first 7 characters from each line in the file???
    How do i do it...
    Any help will be appreciated...

    Dear Friend,
    Thankyou very much for your interest.
    I am trying to strip the 1st 7 characters from the following file while reading....
    1. <?xml version="1.0" encoding="UTF-8"?>
    2.
    3. <DOCUMENT>
    4. <GREETING>
    5. THE LIVE EXAMPLE...
    6. <MESSAGE>
    7. </GREETING
    8. If this works then your project is over...;;;
    9. </MESSAGE>
    10. </DOCUMENT>
    I meant, if my file contains line break (space of a line between two lines just like in Double Line spacing. Eg. between 1 and 3).... the program doesn't read after reading the first line. Your method does stip first seven characters of first line...
    Your help is appreciated....

  • What is system variable to find the current list line in list processing

    hi
    what is system variable to find the current list line in list processing

    Hi,
    Please find below the system variable related to list processing
    LILLI    INT4     10     Processing lists       List line selected
    LINCT  INT4     10     Creating lists           Page length in a list
    LINNO INT4     10     Creating lists            Current line
    LINSZ  INT4     10     Creating lists          Line width in a list
    LISEL  CHAR     255     Processing lists       Contents of the chosen line
    LISTI    INT4     10     Processing lists       Index of the chosen list
    Thanks,
    Muthu.

  • Limiting characters in a line

    How do you limit char in a line
    Ex
    1 st line has 1 char
    2 nd line has 2chars
    3 rd line has 3 chars
    4 th line has 4 chars
    & so on
    any help would be appereciated.

    > any help would be appereciated.
    Yes, we know you need to make an alphabetical
    triangle completed with *'s.
    Input "h" should produce:
    A
    BC
    DEF
    GH**All very clear described in your previous thread
    http://forum.java.sun.com/thread.jspa?threadID=688845
    I gave you a start but you kept begging for code. How
    about trying it yourself? If you get stuck, post the
    code here and I'm sure someone will give you a hand.
    To refresh your memory, here is my hint again:
    char letter = 'H';
    for(int i = (int)'A'; i <= (int)letter; i++) {
    c.print((char)i);
    My teacher said i need to limit the characters in the line.
    1 has 1
    2 has 2
    and so on

  • How do I find the dc load line for a BJT on multisim 11

    Im trying to find the dc load line for a BJT on multisim 11.

    Thanks for reply. Would please tell me the procedure to get output jfet characteristic curve by changing d-s voltage at different g-s voltage to drain current? I attached my document. It's better if you send me a sample simulation file if possilble. actually i will try for other jfet model once i know how to simulate it. it would be great help. thank you in advance.
    Attachments:
    expecting waveform.JPG ‏32 KB
    char.JPG ‏345 KB

  • Finding nr of "new-line"-characters in string

    Hi!
    I looking for a smooth way of achieveing the number of "\n" characters in a string.
    e.g.
    String tmp = "There is a house\n in New Orleans, \n they call the Rising Sun\n";
    This string should return number 3 (three occurrences of the '\n' character.
    How ?
    /Rickard

    I'm not sure if this is the best way to do this but it works ok,
    String tmp = "There is a house\n in New Orleans, \n they call the Rising Sun\n";
    java.util.StringTokenizer st = new java.util.StringTokenizer(tmp, System.getProperty("line.separator"));
    int counter = 0;
    while(st.hasMoreTokens()) {
         st.nextToken();
         counter++;
    }

  • Mountain Lion Mail cannot search for non-alpha characters in Subject Lines

    Under 10.8.3, Mail 6.3 often cannot successfully find messages if the search string contains a non-alpha character.
    I have only tested this searching for Subject lines that are KNOWN to contain non-alpha characters
    Specfic examples:
    Subject starts with "[ABC..."
    Mail cannot find it if you search using "[ABC"
    Mail CAN find it if you search using just "ABC"
    Subject contains the numeral "2"
    Mail cannont find it if you enter "2" as the search string...even if you further constrain the search to "Subject contains: 2"
    Other problem characters I have found:
    The failure when using square bracket is a real pain since a lot of mailing lists are tagged using strings wrapped in square brackets.
    Sometimes it WORKS when I include multiple non-alpha characters in the search string, like "55" or "4/19"
    Anyone else see this?

    Please follow these directions to delete the Mail "sandbox" folder.
    Back up all data.
    Triple-click anywhere in the line below on this page to select it:
    ~/Library/Containers/com.apple.mail
    Right-click or control-click the highlighted line and select
    Services ▹ Reveal
    from the contextual menu.* A Finder window should open with a folder named "com.apple.mail" selected. If it does, move the selected folder — not just its contents — to the Desktop. Leave the Finder window open for now.
    Log out and log back in. Launch Mail and test. If the problem is resolved, you may have to recreate some of your Mail settings. You can then delete the folder you moved and close the Finder window. If you still have the problem, quit Mail again and put the folder back where it was, overwriting the one that may have been created in its place. Post your results.
    Caution: If you change any of the contents of the sandbox, but leave the folder itself in place, Mail may crash or not launch at all. Deleting the whole sandbox will cause it to be rebuilt automatically.
    *If you don't see the contextual menu item, copy the selected text to the Clipboard by pressing the key combinationcommand-C. In the Finder, select
    Go ▹ Go to Folder...
    from the menu bar, paste into the box that opens (command-V). You won't see what you pasted because a line break is included. Press return.

  • [PART SOLVED] Random j, k characters appearing on lines. A vim issue?

    Hi There,
    I recently noticed that when scrolling around a file using the keys j and k in normal mode that random j and k characters appear at the end of lines. Initially I thought this was a terminal issue so I switched terminals, no luck. I removed all erroneous crap from .vim, no luck. I have googled around a bit, and it appears this is a known issue with jslint, but this is occuring with no plugins. Ctrl-l removes the random characters, and they don't appear to be getting written to the file, but it is annoying non the less.
    Any thoughts?
    Thanks.
    Last edited by ZombieX (2012-05-25 12:36:50)

    Thanks for the reply. In my case, it appears more frequent when you scroll back and forth over pages using j and k. I haven't noticed anything with the 'O' command but I will keep an I out. I haven't been able to find the root cause of this, nor have I found any 'real' fixes so I either deal with it or use emacs with VIM bindings. I'll consider this closed.

  • How to find the paragraph and line numbers [CS3] [JS]

    Hello,
    I have a script that finds certain text formatting. Rather than having the script select all the instances of this text I have an alert that lists the page number and the contents for each found instance. The following gets those.
    var pageNumber = myFoundSet[n].parentTextFrames[0].parent.name;
    var foundContents = myFoundSet[n].contents;
    However, I would like to include the number of the paragraph where the found text resides as well as the line number in that paragraph.
    I am stumped on how to do this. Would be nice if there were a parentParagraph and a parentLine.
    Can someone point me in a direction?
    Thanks,
    Tom

    Tom,
    Assuming that you're looking for the number of the paragraph on the page, you'd need to count the number of paragraphs in the text frame that a found item occurs in. Since indexes are always counted from the beginning of the story, you isolate the text between the top of the page and the found item by starting at the index of the first insertion point of the found item's parent text frame and the found item itself. You capture that with this single long line:
    // range over ...
    paragraph_number = myFoundSet[n].parentStory.characters.itemByRange (
       // ... index of first ins. point of found item's parent text frame ...
       myFoundSet[n].parentTextFrames[0].insertionPoints[0].index,
       // ... and index of found item
       myFoundSet[n].index
       ).paragraphs.length;
    This includes any paragraph that started on the previous page. To find the found item's line number within its parent paragraph you do something similar:
    line_number = myFoundSet[n].parentStory.characters.itemByRange (
       myFoundSet[n].paragraphs[0].index, //first insertion point of paragraph
       myFoundSet[n].index
       ).lines.length;
    There's no need for parentParagraph and parentLine: myFoundSet[n].paragraphs[0] returns an item's parent paragraph, myFoundSet[n].lines[0], the item's parent line.
    Peter

  • Mail repeats characters in heading lines

    Hi
    since I upgraded to Leopard Mail.app started with this strange behavior: I can enter only one address per line. When I try to enter a second one, it starts repeating the characters I enter in sequence. For instance, if I try to enter the word "Peter" what I get is "ppepetpetepeter" (which is, by the way ppe+pet+pepepeter). It's like if when I enter one character the system copies it and enters it again together with the next.
    Besides, I cannot delete these strange characters. The only way to remove them is to select and copy them.
    I've found this same behavior in other apps. For instance, in the tagging line of Leap.
    In Address Book is even worse. It does the same thing but in the end doesn't let me save the changes to any address.
    I have all the system upgrades, and a previous generation iMac.
    Does anyone has a clue about what's causing this?
    Thanx in advance
    João

    J.
    In the original User Account, try quitting Mail, and then in the Finder open Home/Library/Preferences and find the com.apple.mail.plist file and delete it. Then relaunch Mail and set your accounts up again, and decline to import anything. Mail should then rediscover your account folders.
    Removing the com.apple.mail.plist file will not threaten the contents of your On My Mac mailboxes (which are in the Mailboxes folder and not any account folder). However, for complete safety make a duplicate of either the Mailboxes folder or the entire Mail folder, and temporarily keep that copy on your Desktop for backup.
    Ernie

  • Find and edit specific line in text file?

    Hello I want to read a text file that could look in some different ways since the user choose file from a list. I then want to igonre all the lines that begin with a special character, for example %. I then want to find all the lines "words" that begin with TRY for example and put those "words" in a string or array. If there is one line that contains TRY100 and anoter line that contains TRY200 I want to find those words and display them. How do i do this?

    First you read the entire file.  Use the Read Text File.  Right-click on it and select the option to Read Lines.  The the count to read to -1 (read all).  You will now have an array of strings, one item for each line of your file.
    Now you need to play the filter game.  I recommend using FOR loops with Autoindexing tunnels.  Assuming you are using 2012 or later, have the output autoindexing tunnels use the conditional tunnel.
    Give this a try and see where you can go.  Post back with what you have tried and tell us where you are stuck.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

Maybe you are looking for

  • Passing values to jSP on button click

    Hello I have multiple delete buttons on the JSP page. What i want is to get the value as to which delete button was clicked. I am not sure if i shld have multiple names for the buttons. For now all have the same name since its inside a while loop. Al

  • Pl/sql help - go to next record

    Hi all, im kind of new at sql, Ive got a form, i made using J Developer Form Builder, that displays data from a database in a series of text boxes, im looking to make a set of buttons that navigate threw the records, i think it would be comething lik

  • Restore standard hierarchy

    Hi we have a situation where client going for  restructuring of standard hierarchy.  After the restructuring in case the restructuring is not in the desired structure we need to get back to the old situation. one thing we can do is to export the exis

  • Firefox 18.0 crashes when I shut down Firefox on a 32-bit computer. OK in 64-bit computer.

    Firefox 18.0 works well when I open it on a 32-bit desktop. I can open any website (I use only one tab). But when I shut down Firefox, I get the "Firefox crashed" message. It reloads ok, but I've never had this problem with any Firefox version before

  • New iMacs and second display

    I'm looking at getting a new 20" iMac and looking at both versions. My main concern is that I already have an older Apple 20" cinema display (the kind with 2 plastic legs) that I want to hook up as a second, extended desktop monitor. The first iMac h