How to use PHP regex to replace a space AND comma AND combination of space AND comma with arbitrary string?
Date : March 29 2020, 07:55 AM
wish help you to fix your issue How do you use PHP's preg_match to replace: preg_replace('/[\s,]+/', 'YES', $str);
|
Linux bash: how to replace 2 words in a file from bash command line
Date : March 29 2020, 07:55 AM
hope this fix your issue I need to replace 2 words in a file from Bash command line, for example: fileA.txt , You could try the below sed command, sed -i 's/AA BB/CC DD/g' file
$ echo 'xxxx AA BB xxx' | sed 's/AA BB/CC DD/g'
xxxx CC DD xxx
awk '{sub(/AA BB/,"CC DD")}1' infile > outfile
$ echo 'xxxx AA BB xxx' | awk '{sub(/AA BB/,"CC DD")}1'
xxxx CC DD xxx
|
Bash replace a comma with space colon space sequence
Date : March 29 2020, 07:55 AM
wish of those help tr -d is usually used for deleting characters. If you want a quick way to replace commas with a space-colon-space sequence1, just use: sed 's/,/ : /g' testfile
sed -i.bak 's/,/ : /g' testfile
mv testfile testfile.bak
sed 's/,/ : /g' testfile.bak >testfile
tr ',' ':' <testfile
mv testfile testfile.bak
tr ',' ':' <testfile.bak >testfile
|
How to replace comma with space in text file using VBA
Tag : vba , By : Nate Bedortha
Date : March 29 2020, 07:55 AM
it helps some times I have data in a text file (input.jpg). I want to replace the comma with the space and align the data in one line.Please see the output text file (output.jpg). , This should do the trick: Sub foo()
Dim objFSO
Const ForReading = 1
Const ForWriting = 2
Dim objTS 'define a TextStream object
Dim strContents As String
Dim fileSpec As String
fileSpec = "C:\Test.txt" 'change the path to whatever yours ought to be
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTS = objFSO.OpenTextFile(fileSpec, ForReading)
Do While Not objTS.AtEndOfStream
strContents = strContents & " " & objTS.ReadLine 'Read line by line and store all lines in strContents
Loop
strContents = Replace(strContents, ",", " ")
objTS.Close
Set objTS = objFSO.OpenTextFile(fileSpec, ForWriting)
objTS.Write strContents
objTS.Close
End Sub
|
How can I cut each line in a file when it reaches a space or comma in bash?
Date : March 29 2020, 07:55 AM
this one helps. I basically want the first word of each sentence in a file, but since words can be followed by punctuation, cutting after a space doesn't do it. , Could you please try following. With sed: sed -E 's/(^[a-zA-Z]+).*/\1/' Input_file
awk 'match($0,/^[a-zA-Z]+/){print substr($0,RSTART,RLENGTH)}' Input_file
awk 'match($0,/^[a-zA-Z]+\(\)-/){print substr($0,RSTART,RLENGTH)}' Input_file
awk 'match($0,/^[[:alpha:]()-]+/){print substr($0,RSTART,RLENGTH)}' Input_file
|