Questions tagged [string-manipulation]
The string-manipulation tag has no usage guidance.
108
questions
1
vote
1
answer
46
views
Check string with negative decimal values contains special characters
I need to check if a string with negative values contains special characters. When I type -7.!, -7.@, -7.# the special characters are found, the error message is sent and the program is closed, but ...
2
votes
1
answer
121
views
Bash or zsh conditional patterns and variable expansions
Suppose I want to generate a filename based on some given variables.
track=01
title="Some title"
album="Some album"
echo ${track}. ${title} (${album})
-> 01. Some title (Some ...
3
votes
1
answer
130
views
Powershell: Using .Split on Filename functioning differently based on filename capitalization
I have a bunch of image files that accidentally got renamed with a "doubled" file extension (e.g. IMG_1469.jpg.jpg). I wrote a script to remove the extra file extension, but for some reason, ...
0
votes
1
answer
96
views
How do I delete text between 2 strings?
I have tried the regex expression .a href.*?..a. and .a href[^:]++..a.
I want to replace .a href=.u.gogogo98. class=.3t5uN8xUmg0TOwRCOGQEcU rel=noopener nofollow ugc target=.blank..u.gogogo98..a. with ...
0
votes
2
answers
66
views
Notepad ++ / Extract text betwen ^ ^ and add it, as new line
I have a text file that I need to extract specific data elements from it ( the person fullname to add it as new line):
ID:363712^CLARK/DEJA G^:e30276c2f826febd3784958:KZxhnbUUouxvMrTEYfGnDZ7YcGjPh
ID:...
2
votes
2
answers
1k
views
Batch - Extract string before the specified character
How to get the string before the character hyphen? The following code gets the string after the hyphen. How can I reverse this?
set string=1.0.10-SNAPSHOT
echo %string:*-=%
SNAPSHOT
But I want the ...
0
votes
1
answer
28
views
How to increment group numbers in a settings file?
I have an application with a settings file (.ini) that contains data in the common format:
[group1]
foo=bar
bar=baz
...
[group2]
foo=bar
bar=baz
...
...
[group500]
foo=bar
bar=baz
...
where the ...
0
votes
3
answers
1k
views
Windows command dir lists files with absolute path, relative path required
I would like to list all filesnames of all files with a specific extension in a directory structure and write this to a file. What I have reached:
dir /B /S *.ext > list.filenames
This gives me a ...
0
votes
1
answer
79
views
Excel: Extract a project number from a text string (various position and length)
In an Excel spreadsheet I have a column of mixed text strings containing project master data (type, project no., address, theme and such). From this string I need to extract the project number in an ...
3
votes
1
answer
321
views
Remove spaces from first column of delimited file
I have a very large colon-delimited file with two columns:
dhsj fdksjdk:dndkdlkfkd
shfdosod dkjsosjd:dkj dosjeod
dhswisoaidodisbw: dhsoi wjdos
fjfdododjfideefkjso sn:fhfdkd dkdjdf
If the first ...
0
votes
1
answer
40
views
how to extract multiple words from sentence that have same ending to a new column separated by commas
I have an issue whereby for example i have a sentence in column A that says for "hello ID users tbzoo, rjkth, mnkz, plzoo, rtzoo and fghzt" and i would like to create a new column B that ...
0
votes
1
answer
119
views
Excel - How to split a string by a list of delimiters
As part of a board game logging tool, I want to be able to split a string.
The string may consist of the following:
Allowed characters: 00,0,1,2,3,4,5,6,C,B,R. Besides 00, any numbers will always be ...
0
votes
1
answer
1k
views
Best way to store multiple values from a running process into variables in bash
The problem
Starting a process will output sensitive information on the bash. I want to extract this value of an occuring pattern and assign it to bash variables. In concrete, starting the process ...
4
votes
1
answer
1k
views
In convert case, what is the difference between blend and normal version?
In notepad++, if you go to Edit > Convert Case to, you have entries like:
Proper Case
Proper Case (blend)
Sentence case
Sentence case (blend)
What is the difference between blend and "normal" ...
2
votes
1
answer
144
views
How does this find state actually work in moving a file up one directory?
Can someone explain how the string manipulation in this find statement actually works? My head is about to explode trying to figure it out. :-o
From: UNIX shell scripting: how to recursively move ...
3
votes
1
answer
145
views
joining lines while adding white-spaces to select strings in CMD does not always work
here is an ordinary .bat that joins all lines and leaves a whitespace between the resulting strings.
@echo off
setlocal EnableDelayedExpansion
set row=
@For /F "EOL=|" %%x In ('^""%__AppDir__%find....
0
votes
1
answer
2k
views
In Bash how to get the position of a substring, within a string, starting the search at character position n
I am new to Bash scripting, I've used Visual Basic in Windows before and am looking for a bash equivalent string function for VB's inStr().
example in VB :
strMain = "abcABC123ABCabc"
searchStartPos ...
1
vote
3
answers
4k
views
How to extract a part of a line that is between two specific strings via a batch script
I am trying to extract strings which are between testid= and ].
Input text file
SEVERE TEST 11/18/2019 8:00:41 AM Could not find INPUT with [testid=2345]
SEVERE TEST 11/18/2019 5:02:11 AM Could ...
1
vote
1
answer
163
views
replace sub-string with last special character, being (3rd part) of comma separated string
I have a string with comma separated values, like:
742108,SOME-STRING_A_-BLAHBLAH_1-4MP0RTTYE,SOME-STRING_A_-BLAHBLAH_1-4MP0-,,,
As you can see, the 3rd comma separated value has sometimes special ...
1
vote
1
answer
28
views
How to format Excel cells to show only a certain part of the code my scanner scans from certain objects?
For ex:
When I scan an qr code it shows:
Column A1
vbmsavchjas asdhgaskhdgaskhdg_INX7642854858625
but I am only interest in the last characters:
Column B1
INX7642854858625
I can use afterwards in ...
1
vote
2
answers
120
views
how to split a string in two then assign each segment into a variable
I have this code:
#!/bin/sh
echo "--------- Backup config files -------------"
find /vmfs/volumes/datastore1/ \
-type f \
-regex '.*\.\(vmx\|nvram\|vmsd\|vmdk\)$' \
! -name '*-flat.vmdk' \
-...
3
votes
1
answer
696
views
Use find and do command on filename without "./" prefix
Performing a cp on filenames in multiple subdirectories and prefix them with foo- leads to an error:
$ find my-dir -path "*/*" -execdir sh -c 'cp {} foo-{}' \;
cannot create regular file ‘foo-./...
1
vote
3
answers
2k
views
How to reverse a string in Excel?
Is there an Excel function (or macro) I can use to reverse a string. i.e. to turn these words into sdrow eseht?
Here is why I need that:
My strings are similar to John|XYZ Street|215|USA and I need ...
2
votes
1
answer
228
views
sed: match a string between two different consecutive matches on all occurrencies
i have:
bananaOPENqwertyCLOSErandomtextOPENgrapesCLOSEwhateverOPENsunshineCLOSEgreymoon
this line could have many more OPEN and CLOSE strings in it.
I want to print the whole line with only ...
0
votes
1
answer
124
views
How to add 'filler' characters up to N limit to a variable length string using Excel / Sheets formulae?
I have a list of strings (names / description text) that I need to add 'filler' characters to.
The maximum string length is 32 - for any text under that (in characters) I need to add special filler ...
1
vote
1
answer
124
views
Surround certain string with specified characters using regex-capable editor
I need to format certain string in Sphinx's documentation H2 Header.
Example:
v-add-user should be replaced with
*********
v-add-user
*********
I search for needed string in Notepad++ (regex ^(...
4
votes
2
answers
2k
views
How to remove extension from pathname passed as {} in `find -exec`?
Given the situation that audio needs to be extracted from video files residing in subdirectories, how would one go about properly naming the resulting files?
The following one-liner works, but ...
0
votes
1
answer
42
views
`tr` replaces more than I expected
I have a load of files from my teaching job that I want to put in OneDrive on a regular backup. My colleagues are bad at naming files, so they need a cleanup for OneDrive to take them.
The bit that ...
0
votes
0
answers
730
views
Recursive and massive string replace inside Windows folder
I have a text file with oldstr<tab>newstring lines to replace inside all source files like this:
MyOldText (tab) MyNewText
MyOldText2 (tab) MyNewText2
How can I massively replace ...
0
votes
2
answers
45
views
How can I insert the original matched pattern (OLD STRING) into the result (NEW STRING) Using Microsoft Word's Find/Replace Feature?
Microsoft Word's find/replace feature seems like it is many-to-one.
Suppose that we have a word document numbers surrounded by parentheses, such as (6)
and we want to remove the parentheses and place ...
0
votes
1
answer
316
views
Busybox filter string list
Consider I have a list like this:
list='item1.service item2.service item3.target item4.service'
I need to filter this list to get something as:
item1 item2 item4
So, there are two things to notice:...
1
vote
1
answer
52
views
Extracting filenames from svn console output
My Tortoise SVN SVN update command generally returns me this output:
C:\proj>svn update
Updating '.':
A 'some-file1.txt'
D 'some-file2.txt'
Restored 'some-file3.txt'
U 'some'file4.txt'
C 'some ...
1
vote
1
answer
46
views
How to extract multiple urls from String?
I have a string like below
https://website.com/BTAE/2015/BTAE assignment jan 15.pdf²0ÔË'\„QI„"ÙP¾^ŒŸZ‡@Æ*]Ü.^‚vðƒ€Ù¾»Æš©Šñ‘€é•
ªÂIR#œÉgÉÛ^gMdÉ%9¬e˜Hžôb¿'0<ô ?lþzk…éÃÄórÈ;EW¦K³1…²ì¶ZFžŠÒô*ÄÖ\...
0
votes
1
answer
96
views
Editing strings that are followed by a punctuation mark in Microsoft Word [closed]
I have a Microsoft Word document with two sections of text. The first is in paragraph form, the second is that paragraph form broken down into segments and placed in a table without punctuation. Is ...
3
votes
4
answers
7k
views
Linux command to remove the duplicate lines but keep the first occurrence
I have a text file. Each line contains a string. Some strings are repeated. I want to remove repetition but I want to keep the first occurrence. For example:
line1
line1
line2
line3
line4
line3
line5
...
1
vote
4
answers
1k
views
How to get string between the last two "/" symbols
I am using Bash. I have some string of paths, like /dir0/dir1/dir2/filename.ext and I want to extract the string dir2 in bash.
You can assume that the word I want to extract is located between the two ...
0
votes
1
answer
808
views
How to split single row CSV?
I have a CSV file that imports like this:
Field1_Entry1,Field2_Entry1,...FieldN_Entry1,Field1_Entry2,Field2_Entry2...
I intend to have a new row after Field N so I get a table with N columns:
...
6
votes
1
answer
2k
views
Replace every 6th pipe in powershell
I realize I'm asking a similar question that was already asked and answered but I was not able to extrapolate the answer I needed since the regex and regex engine is different enough. I have hardware ...
1
vote
3
answers
7k
views
bash - Find difference between two variables
I have two variables: var1="1, 2, 3, 4" and var2="3, 4, 5, 6".
I'd like to get a new one, var3, containing the differences between $var1 and $var2.
The expected result should be var3=1, 2, 5, 6.
I ...
0
votes
1
answer
2k
views
Rename-Item using -Replace with multiple patterns
Consider the files:
File1 (Custom).jpg
File2(Custom).jpg
I need to rename the files to strip away" (Custom)" and/or "(Custom)" from their Name string (notice the space before the opening parenthesis)...
0
votes
1
answer
539
views
Parse RegEx in Excel
Suppose I have some Excel spreadsheet with the following column:
A-345 hello
hola B-389
nice C-6231
what A-12287 who
just A-7819 C-45556
As you can see - I have a text combined with some RegEx ...
0
votes
1
answer
112
views
How to insert CR before text pattern #:## in Excel cell text
I have large amounts of text in cells of a multi-row Excel spreadsheet. The text blocks in the cells are broken up by time stamps, e.g., “16:43” or, in some cases “4:43 PM”. I'd like to parse for the ...
1
vote
1
answer
612
views
How to get only IP address from nmblookup for use in Bash script?
If I do:
nmblookup myServerName
I get:
192.168.6.106 myservername<00>
Since I want to use the IP returned from nmblookup myServerName in a Bash script, I'd like to know the best way to ...
1
vote
1
answer
1k
views
How to split initials from names, in MS Excel?
I have a list of (around 1200) names in MS Excel which are in several different formats.
Full names with 3 parts - ex: John Maynard Keynes
Full names with 4 parts - ex: Mohomad Hussain Mohomad Niyas ...
0
votes
2
answers
165
views
Return specific matched (sub) value with grep in linux
I'm running a Zabbix agent (logging software) on Ubuntu and wish to ping an internal IPIP/GRE Tunnel to constantly measure the quality of the connection.
Now a Zabbix agent does not by default allow ...
1
vote
1
answer
509
views
Camel-casing a 'dashed' string
I'm fairly inexperienced with *nix scripting, and I have a need to take a string with lowercase words separated by dashes and convert that to a new string with the dashes removed, and the first letter ...
2
votes
2
answers
3k
views
How to select the first number in cell in Excel?
I have a table that stores both a number and some text in a cell, and I want to do an arithmetic operation based on the numbers. So my table looks like this:
Number1 | Number2 | Product
2 ...
0
votes
2
answers
811
views
Parsing a text string in Excel
I have the following strings of text in Excel cells and need to get the value with the "%" symbol. I have tried several approaches with FIND, MID, LEN, SUBSTITUTE, etc., but haven't found the ...
16
votes
7
answers
18k
views
How to split a string with quotes (like command arguments) in bash?
I have a string like this:
"aString that may haveSpaces IN IT" bar foo "bamboo" "bam boo"
I want to be able to split it like this:
aString that may haveSpaces IN IT
bar
foo
bamboo
bam boo
...
0
votes
1
answer
322
views
MS Excel: MIN and FIND/SEARCH
I am trying to figure out what exactly excel is doing with these two functions.
I have many rows of strings in a single column. I want to pull out the first numeric in those strings. The first number ...