Question

java find and replace code pls help me We write code that can find and replace...

java find and replace code pls help me
We write code that can find and replace in a given text file. The code you write should take the parameters as command line arguments:

java FindReplace -i <input file> -f "<find-string>" -r "<replace-string> -o <output file>

*question mark(?) can be used instead of any character.

"?al" string an be sal ,kal,val

*In addition, a certain set of characters can be given in brackets.(

"kng[a,b,f,d,s]ne" string an be kngane,hngbne,kangfne,kangdne,kangsne

So, all you have to do is match all strings that match <find - string> in the input file <replace -string> and output (output the entire contents of the input file) output file.
The input file needs to remain unchanged. Input and output files will be a text file. Both strings will be separated by a double quotation mark (") character. To change these special characters in Java
you will need to enter an escape character (backslash) like

examples=

java FindReplace -i input.txt -f "sam?jack[3,4,5]" -r "samjack49" -o output.txt

java FindReplace -i doc -f "sam-jack fou?rth nine fifth" -r "sam jack 49 50 " -o doc2

java FindReplace -i input -o output -r "-f" -f "-r"

[replace input -r with -f and write result to output file]

java FindReplace -o out -i inp -f "\[\]" -r "{}"

[replace input [] with {} and write result to output file]

java FindReplace -i input.txt -o output.txt -f "\[?\]" -r "[a]"

[bracketed strings with single characters in it. Replace with [a]]

java FindReplace -i input -o output -f "\?" -r "question mark"

java FindReplace -o out -i input -f "\"" -r " ' "

java FindReplace -i inp -f "sam" -r "jack"

***PLS   regex mechanism will not be used.

!!!!!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

.ed uSonner Sc: new scanner (fir), in S e lse P. Pint In (st)3 Puo.closcc Puu. closeC) Foud clos SC close o, Catch CEx ception e) e printS tacKae

Add a comment
Know the answer?
Add Answer to:
java find and replace code pls help me We write code that can find and replace...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • NEED THIS SOON. Recursive Descent Parsing Consider the following BNF grammar: A -> I = E...

    NEED THIS SOON. Recursive Descent Parsing Consider the following BNF grammar: A -> I = E E -> P O P | P O -> + | - | * | / | ** P -> I | L | UI | UL | (E) U -> + | - | ! I -> C | CI C -> a | b | ... | y | z L -> D | DL D -> 0 | 1 | ......

  • JAVA Which of these statements does not match by using exception action in Java? 1. Exception...

    JAVA Which of these statements does not match by using exception action in Java? 1. Exception action makes it possible for the calling method to handle errors in called methods.    2. Exception action simplifies programming since incorrect reporting and handling can be located in catch blocks separately from the rest of the code.    3. Exception action increases the performance of programs. 4. Java separates exception action from common processes. Why create instances of File Class? - several alternatives...

  • //I NEED THE PROGRAM IN C LANGUAGE!// QUESTION: I need you to write a program which...

    //I NEED THE PROGRAM IN C LANGUAGE!// QUESTION: I need you to write a program which manipulates text from an input file using the string library. Your program will accept command line arguments for the input and output file names as well as a list of blacklisted words. There are two major features in this programming: 1. Given an input file with text and a list of words, find and replace every use of these blacklisted words with the string...

  • I need some help with Java. I need to write a Java program that generates a...

    I need some help with Java. I need to write a Java program that generates a set of random strings from a given string of same length where no character is ever repeated and character belong to the original string. See example. Example Input: “Hello World” (length 9) Output: “World oHlel” (length 9)

  • Using C++, and <iostream> if possible, ​ Write a program that can compress a text file...

    Using C++, and <iostream> if possible, ​ Write a program that can compress a text file consisting of English language alphabet A-zl using run-length encoding scheme. (Weight 50%) Run-Length Encoding The key idea is to replace the repeating character by itself and the number of times that it has been repeated. Consider the following string HELLO WORLD This can be re-written as HEL20 WORLD Notice that since LL was repeated, it was repeated by L2. 2 here indicates that letter...

  • In this part of the assignment, you will write MIPS assembly code to replace characters in...

    In this part of the assignment, you will write MIPS assembly code to replace characters in a string. This program asks the user for a string named string and two characters orig and new. It then replaces each instance of the character orig found in string with the character new. It outputs the resulting string and the number of substitutions that were made. For example, if string were "wow", orig were 'w', and new were 'b', the program would output...

  • Write a program in java to read a string object consisting 300 characters or more using...

    Write a program in java to read a string object consisting 300 characters or more using index input Stream reader. The program should perform following operations. The String must have proper words and all kind of characters.(Use String class methods). a, Determine the length of the string count the number of letters in the strings , count the number of numeric object d. Calculate the number of special character e. Compute the ratio of the numeric to the total f....

  • For this lab you will write a Java program that plays a simple Guess The Word...

    For this lab you will write a Java program that plays a simple Guess The Word game. The program will prompt the user to enter the name of a file containing a list of words. These words mustbe stored in an ArrayList, and the program will not know how many words are in the file before it starts putting them in the list. When all of the words have been read from the file, the program randomly chooses one word...

  • Recursive Descent Parsing Consider the following BNF grammar: A -> I = E E -> P...

    Recursive Descent Parsing Consider the following BNF grammar: A -> I = E E -> P O P | P O -> + | - | * | / | ** P -> I | L | UI | UL | (E) U -> + | - | ! I -> C | CI C -> a | b | ... | y | z L -> D | DL D -> 0 | 1 | ... | 8 |...

  • Write a program that can remove spaces from an input string, find the indexes of a...

    Write a program that can remove spaces from an input string, find the indexes of a character within the string and replace that character with another character. Here is an example input: I am an input string a b The first line, "I am an input string" represents the input string. Please put it into a string variable using getline. In the second line "a b", a is the character that needs to be located within the input string, and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT