Questions tagged [string-manipulation]
The string-manipulation tag has no usage guidance.
114
questions
1
vote
3
answers
52
views
How to strip suffix with basename inside a find -exec command?
I have not found a way to do the following example with find:
$ find . -name "*.mp3" -exec echo $(basename "{}" ".mp3") \;
I expected the basename command to remove ...
0
votes
1
answer
21
views
Split readings data into multiple lines
I have a text file containing data about the correspondence of readings and characters in the following style (not actual data, but exactly the same style):
yī 一伊依医
yí 乁仪侇仪冝凒
yǐ 乙以佁侜倚偯尻崺已
yì 乂义
I ...
1
vote
0
answers
81
views
Sublime Text 4 sql highlight inside a string
Currently, if I have sql commands inside a python string, Sublime Text highlights it. However if it's an "f string", it does not recognize the sql inside. Is there any way to make it work ...
1
vote
1
answer
149
views
Function to calculate length of a string in Google Spreadsheets when the string contains certain UTF-8 characters
This function returns 6 and it's expected to return 4:
=LEN("🥎A🥎B")
What function should I use to get the "real char count" expecting that one symbol in the UTF-8 icon map is 1 ...
0
votes
0
answers
40
views
How to fill a column getting a substring of another one with a rule
I'm trying to play with the functions LEFT, RIGHT and SEARCH to fill a column with the name of a function extracted from another column, but I don't get any good result.
I have a list of functions ...
1
vote
1
answer
154
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
577
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
1k
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
1k
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
526
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
5k
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
81
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
4k
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
254
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
1k
views
Remove spaces from first column of colon-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
41
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
147
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
2k
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 ...
6
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
156
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
165
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
2
answers
4k
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
6k
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
316
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
35
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
164
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
918
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
514
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
363
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
171
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 ^(...
9
votes
2
answers
6k
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
48
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
860
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
67
views
How can I insert the original matched pattern (OLD STRING) into the result (NEW STRING) Using Microsoft Word's Find/Replace Feature?
The find/replace feature in Microsoft Word usually has the same resulting output string no matter what input string matches the search pattern.
INPUT
OUTPUT
(1)
1.
(2)
1.
(3)
1.
(4)
1.
(5)
1.
(...
0
votes
1
answer
506
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
88
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
67
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
102
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
8k
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
2k
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
919
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
9k
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
3k
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
572
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
114
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
696
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
245
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 ...