Search for a character in a text file

I have a text file generated using utl_file. After this is generated, I want to search for a specific character in the file. If found, I want to edit the file and remove/replace this character.
Any ideas are appreciated.
Thanks

If your application resides on unix box, you can use OS command to find and replace, something like "sed" in unix, do a man on sed and find out the details.

Similar Messages

  • Search for Special Character in  Oracle Text CONTAINS Query

    Hi,
    We have to write few query which will search for email id in the Oracle Text.
    The Search text will be like <[email protected]> .
    So email id should be searched correctly with the @ symbol.
    Similarly we want the following special character to be searched in the Text like ",',*

    You will need to escape the special characters by either using \ in front of each special character or putting {} around the whole phrase that contains the special characters, as per the online documentation:
    http://download.oracle.com/docs/cd/B28359_01/text.111/b28304/cqspcl.htm#CCREF2091

  • Searching for a string in given text file

    Hi,
    I have two strings and i need to search the entire file for the strings and highlight the lines between the strings
    say, for example,
    hi this is xyz
    i am a begineer in java
    can i have some help in this issue please
    i gave 'hi' and 'can' i need the three lines to be highlighted
    can you give me an idea about this.
    how to proceed
    thanks all in advance
    Edited by: anub on Feb 6, 2009 3:24 AM

    Here's an idea. Find a link to the java API. Create a utility class with a method to read a file and a method to write a file. Look in java.io for this. That should keep you busy for a while and give you something specific to ask questions about. Next, create a GUI class and put a button on it. Figure out how to make a button click open a "FileChooser" or "JFileChooser" (Look in the api for that) Imagine that these need to talk to each other so figure out what parameters are needed. After you've done that then figure out how the user is going to enter the two search criteria (something that acts like a text field). Choose a GUI class that supports text highlighting. Display all the information that the user would like to know e.g. The name of the file selected to parse, the name of the file to write, and whether the strings were found successfully.
    kr
    walker

  • Search for a space within a text field

    Hi All
    I am trying to search for a sapce within a text field but sofar not being very successful. I have used:
    FIND search_str
               IN text_str
               MATCH COUNT  lv_mcnt
               MATCH OFFSET lv_moff.
    where search_str = TYPE c VALUE ' '.
    I am looking a way of searching a character within the string using ABAP (like INSTRING in other languages). If you have similiar codes - Could you please post me a copy - Thanks

    HI
    Check this..
    DATA string7(30) TYPE c VALUE 'This is a little sentence.'.
    WRITE: / 'Searched', 'SY-SUBRC', 'SY-FDPOS'.
    ULINE /1(26).
    SEARCH string7 FOR 'X'.
    WRITE: / 'X', sy-subrc UNDER 'SY-SUBRC',
                   sy-fdpos UNDER 'SY-FDPOS'.
    SEARCH string7 FOR 'itt   '.
    WRITE: / 'itt   ', sy-subrc UNDER 'SY-SUBRC',
                       sy-fdpos UNDER 'SY-FDPOS'.
    SEARCH string7 FOR '.e .'.
    WRITE: / '.e .', sy-subrc UNDER 'SY-SUBRC',
                      sy-fdpos UNDER 'SY-FDPOS'.
    SEARCH string7 FOR '*e'.
    WRITE: / '*e ', sy-subrc UNDER 'SY-SUBRC',
                    sy-fdpos UNDER 'SY-FDPOS'.
    SEARCH string7 FOR 's*'.
    WRITE: / 's* ', sy-subrc UNDER 'SY-SUBRC',
                    sy-fdpos UNDER 'SY-FDPOS'.
    Thanks ,
    Praveen

  • How do i search for a string in a txt file using java??

    How do i search for a string in a txt file using java??
    could you please help thanks
    J

    Regular expressinos work just fine, especially when
    searching for patterns. But they seem to be impying
    it's a specific group of characters they're looking
    for, and indexOf() is much faster than a regex.If he's reading from a file, the I/O time will likely swamp any performance hit that regex introduces. I think contains() (or indexOf() if he's not on 5.0 yet) is preferable to regex just because it's simpler. (And in the case of contains(), the name makes for a very clear, direct mapping between your intent and the code that realizes it.)

  • Searching for a string in an excel file and return true if found.

    How can I search for a string in an excel file and return true if found, its location and also a value.

    The problem with searching an excel file is that it contains a header. It would be easiest if you just read the file into a LabVIEW array and search the array. This way you can also get the index and the value of the location.

  • How can I read a specific character from a text file?

    Hi All!
    I would like to read a specific character from a text file, e.g. the 2012th character in a text file with 7034 characters.
    How can I do this?
    Thanks
    Johannes

    just use the skip(long) method of the input stream that reads the text file and skip over the desired number of bytes

  • How to define special character in html text file used in loadvars

    Hi
    I'm witing some maths software and need to use the division
    sign in a text file which is loaded using LoadVars().
    The variable loaded is then assigned to a text area. Here's
    the variable example.
    &hint1=<title><b>Challenge 1: Instant recall
    of any table</b></title><p>Including table
    divisions eg 56 ÷ 8= </p>
    the division sign is missing or a just a box. I've already
    tried most options: &#x00F7; (which works in XML loaded to
    flash), &divide; %F7
    Can anyone help please?

    Hi Michael. Thank you for your reply.
    There is no declaration within sgm file itself - but while opening the file I use sgml application definition with the following settings:
    Default API client:  FmTranslator
    SGML character encoding:  ISO Latin1
    XML character encoding:  UTF-8
    Namespace: Enable
    CSS2 Preferences:
    Generate CSS2: Disable
    Add Fm CSS Attribute To XML: Disable
    Retain Stylesheet Information: Disable
    Entity locations
    Entity search paths
    C:\Program Files\Adobe\FrameMaker9\Structure\sgml\isoents
    So as you can see, character encoding is set to ISO Latin1 (there is no way to use UTF-8 encoding in sgml files)
    Typing ź or ć in sgm document and opening it with framemaker sgml application - I receive: ¿æ and message: "Non-SGML character found; should have been character reference"
    Everything works fine when I type f.ex.: &x016B; and insert appropriate reference lines into isolat1.rw and isolat1.ent files
    But what I would like to avoid is editing those isoent files each time new character is be needed.

  • Search for the end of each text frame?

    I'd like to insert some kind of marker at the end of each of my text frames in order to preserve where the page breaks occur, even after I've exported my file. The only function in InDesign that seems to recognize pages is the text variables that can pull the first/last instance of something on a page. Other than that, I can find no way of searching for the end of a page or end of a text frame.

    myFrames = app.activeDocument.textFrames;
    myCharStyle = app.activeDocument.characterStyles.itemByName("Marker");
    for (a=0; a<myFrames.length; a++){
         if (myFrames[a].characters.length>0){
              myFrames[a].characters[-1].appliedCharacterStyle = myCharStyle;
    The above script will apply a character style called Marker to the last character of all text frames in the document (prepare a character style called Marker [case-sensitive] before you run the script, or change the name in the second line.
    I guess a character style isn't an ideal solution, though, as it might override something else.
    Perhaps a strikethrough? In which case, change the 5th line to:
    myFrames[a].characters[-1].strikeThru = true;
    Does that help?
    Ariel
    www.FreelanceBookDesign.com
    Message was edited by: Arïel to correct syntax error.

  • Delete the specified character in a text file using RandomAccessFile

    Hi All,
    I have an invalid XML file which contains Return characters at the end of each line. I need to delete these return characters so the file becomes valid.
    Does anybody have any idea how this could be done using RandomAccessFile?
    I found joop_eggen's posting in this forum, modified it just a little and wanted to use it, but since the replacement character is "" (blank) it does not do what I need to.
    The XML file looks like this:
    <?xml version="1.0"?>
    <EPMSObject>
    <EPMSRecord><facilityname>KT0</facilityname><date_time>2007-06-01T00:00:00</date_time><devicetype>RPP</devicetype><devicename>RPP1A1_001.BCMF</devicename><meter>BCMF</meter><ckt_01_current>4.136000000000000e+000</ckt_01_current><ckt_02_current>0.000000000000000e+000</ckt_02_current><ckt_03_current>5.521000000000000e+000</ckt_03_current><ckt_04_current>0.000000000000000e+000</ckt_04_current><ckt_05_current>5.880000000000000e+000</ckt_05_current><ckt_06_current>0.000000000000000e+000</ckt_06_current><ckt_07_current>4.086000000000000e+000</ckt_07_current><ckt_08_current>0.000000000000000e+000</ckt_08_current><ckt_09_current>4.994000000000000e+000</ckt_09_current><ckt_10_current>0.000000000000000e+000</ckt_10_current><ckt_11_current>4.374000000000000e+000</ckt_11_current><ckt_12_current>0.000000000000000e+000</ckt_12_current><ckt_13_current>4.314000000000000e+000</ckt_13_current><ckt_14_current>0.000000000000000e+000</ckt_14_current><ckt_15_current>4.112000000000000e+000</ckt_15_current><ckt_16_current>0.000000000000000e+000</ckt_16_current><ckt_17_current>4.287000000000000e+000</ckt_17_current><ckt_18_current>0.000000000000000e+000</ckt_18_current><ckt_19_current>4.254000000000000e+000</ckt_19_current><ckt_20_current>0.000000000000000e+000</ckt_20_current><ckt_21_current>3.970000000000000e+000</ckt_21_current><ckt_22_current>0.000000000000000e+000</ckt_22_current><ckt_23_current>5.640000000000000e+000</ckt_23_current><ckt_24_current>0.000000000000000e+000</ckt_24_current><ckt_25_current>7.123000000000000e+000</ckt_25_current><ckt_26_current>0.000000000000000e+000</ckt_26_current><ckt_27_current>5.118000000000000e+000</ckt_27_current><ckt_28_current>0.000000000000000e+000</ckt_28_current><ckt_29_current>6.094000000000000e+000</ckt_29_current><ckt_30_current>0.000000000000000e+000</ckt_30_current><ckt_31_current>0.000000000000000e+000</ckt_31_current><ckt_32_current>0.000000000000000e+000</ckt_32_current><ckt_33_current>0.000000000000000e+000</ckt_33_current><ckt_34_current>0.000000000000000e+000</ckt_
    34_current><ckt_35_current>0.000000000000000e+000</ckt_35_current><ckt_36_current>0.000000000000000e+000</ckt_36_current><ckt_37_current>0.000000000000000e+000</ckt_37_current><ckt_38_current>0.000000000000000e+000</ckt_38_current><ckt_39_current>0.000000000000000e+000</ckt_39_current><ckt_40_current>0.000000000000000e+000</ckt_40_current><ckt_41_current>0.000000000000000e+000</ckt_41_current><ckt_42_current>0.000000000000000e+000</ckt_42_current></EPMSRecord>
    </EPMSObject>
    Here is joop_eggen's code:
    import java.io.*;
    import java.nio.*;
    import java.nio.channels.*;
    public class Patch {
      private static byte[] sought;
      private static byte[] replacement;
      private static boolean matches(MappedByteBuffer bb, int pos) {
        for (int j = 0; j < sought.length; ++j)
          if (sought[j] != bb.get(pos + j))
            return false;
        return true;
      private static void replace(MappedByteBuffer bb, int pos) {
        for (int j = 0; j < sought.length; ++j)
          byte b = (j < replacement.length)? replacement[j] : (byte)' ';
          bb.put(pos + j, b);
      private static void searchAndReplace(MappedByteBuffer bb, int sz) {
        int replacementsCount = 0;
        for (int pos = 0; pos <= sz - sought.length; ++pos)
          if (matches(bb, pos)) {
            replace(bb, pos);
            pos += sought.length - 1;
            ++replacementsCount;
        System.out.println("" + replacementsCount + " replacements done.");
        // Search for occurrences of the input pattern in the given file
        private static void patch(File f) throws IOException {
        // Open the file and then get a channel from the stream
        RandomAccessFile raf = new RandomAccessFile(f, "rw"); // "rws", "rwd"
        FileChannel fc = raf.getChannel();
        // Get the file's size and then map it into memory
        int sz = (int)fc.size();
        MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_WRITE, 0, sz);
        searchAndReplace(bb, sz);
        bb.force(); // Write back to file, like "flush()"
        // Close the channel and the stream
        raf.close();
        public static void main(String[] args) {
        String E_O_L;
        E_O_L = System.getProperty( "line.separator" );
        if (args.length == 0)
          args = new String[] { E_O_L, "", "C:\\GTI\\EPMSRecords.xml" };
        if (args.length < 3) {
          System.err.println("Usage: java Patch sought replacement file...");
          return;
        sought = args[0].getBytes();
        replacement = args[1].getBytes();
        //if (sought.length != replacement.length) {
          // Better build-in some support for padding with blanks.
          //System.err.println("Usage: sought (" + args[0] + ") and replacement (" + args[1] + ") must have same length");
          //return;
        for (int i = 2; i < args.length; i++) {
          File f = new File(args);
    try {
    patch(f);
    } catch (IOException x) {
    System.err.println(f + ": " + x);
    Thank you,
    Sinan Topuz

    Thank you all.
    Here is what I have right now and it works very well. It takes a couple of seconds to generate the second file and that satisfies me. I took the code sabre150 posted in this forum and changed it just a little bit, so thanks to him.
    I hope this helps someone.
    Sinan
    import java.io.*;
    public class SearchReplace{
        public static void main(String[] args){
            if(null == args || args.length < 2) {
               System.err.println("\nUsage: java <inputFileFullPath> <OutputFileFullPath> \nExample: java C:\\GTI\\Epmsrecord.xml C:\\GTI\\EpmsrecordNEW.xml");
               System.exit(1);
            Reader reader = null;
            Writer writer = null;
            try{
                char cr;
                char lf;
                char sp;
                int  indx;
                cr = '\r';
                lf = '\n';
                sp = ' ';
                indx = 0;
                reader = new FileReader(args[0]);
                writer = new FileWriter(args[1]);
                for (int ch = ' '; (ch = reader.read()) != -1;){
                    indx++;
                    if ( indx > 15 ) {      // Skip the first space character in <?xml version="1.0"?> otherwise the file becomes invaild!
                        if (ch != cr && ch != lf ) {
                            writer.write(ch);
                    }else{
                        writer.write(ch);
                System.out.println("\nFile " + args[1] + " has been successfully created.");
            }catch(FileNotFoundException fnfe){
                System.out.println("\nError : File " + args[0] + " not found. Please make sure it exists and you have rights to access to it.");
            }catch (IOException e) {
                System.err.println("Caught IOException: " +  e.getMessage());
            }finally {
                try {
                    if ( reader!=null ) {
                        reader.close();
                    if ( writer!=null ) {
                        writer.close();
                }catch (IOException e){
                    System.err.println("I/O error occured while trying to close the files.");
    }

  • How to search for a word in a text editor

    Hi,
       I have created a custom container and added some text to it. Is there any method to search for words in this?

    Lilan,
    To search a character field for a particular pattern, use the SEARCH statement as follows:
    SEARCH <c> FOR <str> <options>.
    The statement searches the field <c> for <str> starting at position <n1>. If successful, the return code value of SY-SUBRC is set to 0 and SY-FDPOS is set to the offset of the string in the field <c>. Otherwise, SY-SUBRC is set to 4.
    The search string <str> can have one of the following forms.
    <str>
    Function
    <pattern>
    Searches for <pattern> (any sequence of characters). Trailing blanks are ignored.
    .<pattern>.
    Searches for <pattern>. Trailing blanks are not ignored.
    *<pattern>
    A word ending with <pattern> is sought.
    <pattern>*
    Searches for a word starting with <pattern>.
    Words are separated by blanks, commas, periods, semicolons, colons, question marks, exclamation marks, parentheses, slashes, plus signs, and equal signs.
    <option> in the SEARCH FOR statement can be any of the following:
    ABBREVIATED
    Searches the field <c> for a word containing the string in <str>. The characters can be separated by other characters. The first letter of the word and the string <str> must be the same.
    STARTING AT <n1>
    Searches the field <c> for <str> starting at position <n1>. The result SY-FDPOS refers to the offset relative to <n1> and not to the start of the field.
    ENDING AT <n2>
    Searches the field <c> for <str> up to position <n2>.
    AND MARK
    If the search string is found, all the characters in the search string (and all the characters in between when using ABBREVIATED) are converted to upper case.
    Pls. Mark

  • Searching for XML tags using Oracle Text

    I am using full text search to find documents based on a search text. It works fine for pdf, word documents, etc. However for XML documents, searching for a particular tag name does not find anything. Searching for text within tags works fine. Any thoughts?
    Edited by: miyer on Feb 21, 2011 6:25 PM

    Hi
    Try adding the following variable to ucm config.cfg and then see if a new xml checkin returns the result for FT search :
    TextIndexerFilterFormats=xml
    Save the file , restart UCM and then test .
    If the new checkin gets the results as expected then execute Collection Rebuild cycle to have the existing contents as well FT indexed to be searchable (for XML).
    Thanks
    Srinath

  • LabVIEW for ARM 2009 Read from text file bug

    Hello,
    If you use the read from text file vi for reading text files from a sdcard there is a bug when you select the option "read lines"
    you cannot select how many lines you want to read, it always reads the whole file, which cause a memory fault if you read big files!
    I fixed this in the code (but the software doesn't recognize a EOF anymore..) in CCGByteStreamFileSupport.c
    at row 709 the memory is allocated but it tries to allocate to much (since u only want to read lines).
    looking at the codes it looks like it supposed to allocated 256 for a string:
    Boolean bReadEntireLine = (linemode && (cnt == 0)); 
    if(bReadEntireLine && !cnt) {
      cnt = BUFINCR;    //BUFINCR=256
    but cnt is never false since if you select read lines this is the size of the file!
    the variable linemode is also the size of the file.. STRANGE!
    my solution:
    Boolean bReadEntireLine = (linemode && (cnt > 0));  // ==
     if(bReadEntireLine) {    //if(bReadEntireLine && !cnt) {
      cnt = BUFINCR;
    and now the read line option does work, and reads one line until he sees CR or LF or if the count of 256 is done.
    maybe the code is good but the data link of the vi's to the variables may be not, (cnt and linemode are the size of the file!)
    count should be the number of lines, like chars in char mode.
    linemode should be 0 or 1.
    Hope someone can fix this in the new version!
    greets,
    Wouter
    Wouter.
    "LabVIEW for ARM guru and bug destroyer"

    I have another solution, the EOF works with this one.
    the cnt is the bytes that are not read yet, so the first time it tries to read (and allocate 4 MB).
    you only want to say that if it's in line mode and cnt > 256 (BUFINCR) cnt = BUFINCR
    the next time cnt is the value of the bytes that are not read yet, so the old value minus the line (until CR LF) or if cnt (256) is reached.
    with this solution the program does not try to allocate the whole file but for the max of 256.
    in CCGByteStreamFileSupprt.c row 705
     if(linemode && (cnt>BUFINCR)){
       cnt = BUFINCR;
    don't use the count input when using the vi in line mode. count does not make sense, cnt will be the total file size. also the output will be an array.
    linemode seems to be the value of the file size but I checked this and it is just 0 or 1, so this is good
    update: damn it doesn't work!
    Wouter.
    "LabVIEW for ARM guru and bug destroyer"

  • Is there a way to Search (List search) for more then one field text from a column for Bulk uploading?

    I've been trying to find more information on this and I apologies if this has already been answered. I just don't know the correct way to ask this. We have a SharePoint List at the company that we have people input information into different columns. The
    problem is most of those information are very repetitive. Is there a way for me to search more then one field text in the column and just input that same information in?
    ex:
    Column 1
    Column 2
    Date:
    883851
    MidWest
    User input 
    8831518
    MidWest
    User input
    On the search field in the SharePoint List, I would need to search for 883851, 8831518 etc,  would view those requested numbers, then I would click edit and change dates to those rows. Does that make sense? I'm sorry I'm fairly new at sharepoint.

    I think what you're asking is about having repetitive options in a list, show up easily for new items being created.
    This can be done by setting the columns that contain repetitive information to Choice fields.  In the configuration of the Choice field, check the box for "Allow custom values".  Now as users are entering data into the list, the dropdown of options
    for a given field grows and users can quickly see and select previously entered and thus repetitive values for the given fields.
    I trust that answers your question...
    Thanks
    C
    |
    RSS |
    http://crayveon.com/blog |
    SharePoint Scripts | Twitter |
    Google+ | LinkedIn |
    Facebook | Quix Utilities for SharePoint

  • Search for multiple items in one text field

    Hi all,
    I am new to ApEx, I have a request from one of our users to ask if there is a way we can allow them to enter more than one search items delimited by a comma. For instance, we have a text item field for user to enter some values as emp names, when he key in like PETER,SMITH,ALLEN,WARD, once he submit the page he will see the result as:
    select t.empno, t.ename, t.job, t.mgr, t.hiredate, t.sal
    from scott.emp t
    where t.ename in('PETER','SMITH','ALLEN','WARD')
    Many thanks.
    Message was edited by:
    lcpx

    You can create a multiselect list named P1_REPORT_SEARCH based on a List of Values (LOV) with those employee names and use this code.
    select t.empno, t.ename, t.job, t.mgr, t.hiredate, t.sal
    from emp t
    where
    (instr(':'||:P1_REPORT_SEARCH ||':',':'||ENAME||':') > 0 or :P1_REPORT_SEARCH is null) /**for multiselect**/
    )

Maybe you are looking for