Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [string-manipulation]

The tag has no usage guidance.

0
votes
0answers
4 views

Read substrings from a string containing multiplication [migrated]

I am a scientist programming in Fortran, and I came up with a strange behaviour. In one of my programs I have a string containing several "words", and I want to read all words as substrings. The first ...
0
votes
2answers
38 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
0answers
4 views

String parsing and getting array index from a text string [migrated]

I parse a nested Json file which had nested objects and array and got the result in Map(String, Object). Result that I am able to get: RoomStays.RoomStay.RoomRates.RoomRate[15].Rates.Rate[0].Base....
0
votes
1answer
27 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
1answer
45 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
1answer
28 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
1answer
85 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 ...
2
votes
2answers
680 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
4answers
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
1answer
341 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
1answer
594 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
3answers
2k 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
1answer
740 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
1answer
211 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 ...
0
votes
1answer
89 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
1answer
320 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
1answer
511 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
2answers
77 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
1answer
64 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 ...
1
vote
2answers
971 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
2answers
260 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 ...
6
votes
5answers
7k 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
1answer
83 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 ...
1
vote
0answers
33 views

Parsing (or Converting) Buffered Output

If a dynamic, text-based, CLI application doesn't include an option for producing unbuffered text output; what options do I have for parsing said output? Can it be converted to a more appropriate ...
1
vote
1answer
66 views

Bash: return all the characters between the nth occurence of two different strings within a string

In a bash script (on Ubuntu 14.04) I'm running the command: WP055="$(wget -qO - http://alerts.weather.gov/cap/wwaatmget.php?x=CAZ055&y=1)" Within the WP055 variable string there will be an ...
0
votes
1answer
35 views

Using 'diff' compare usernames from file1 to file2 containing emails

I am trying to identify active accounts over dead accounts and was wondering if diff along with grep or sed or regex can be used, instead of writing a long program. File1 (usernames) ...
10
votes
2answers
2k views

Bash 4.3 Substring Negative Length on OS X

Bash 4.2 added support for negative substring lengths: http://tldp.org/LDP/abs/html/abs-guide.html#SUBSTREXTR01 Example 37-12. Negative parameter in string-extraction construct When the "...
0
votes
1answer
77 views

Extract the first 2 letters in each line of a file using a single command Terminal

I want to extract the first 2 letters of each line from a file and save it in a variable and print it in a single command. Can anyone help me with the command? Considering my file has 20 - 30 lines ...
3
votes
2answers
2k views

Extract a Whole Word From String Containing a Specific Letter or Character

I would like to extract only the word from a cell that contains a specific character ("=") within the text. A2: Dolly made me a homemade=cake and some muffins A3: we had cheese=cake for dinner A4: ...
3
votes
4answers
6k views

Split folder paths in Excel to return the final folder

I have a single column in Excel which has a file and folder path. e.g. C:\1_Folder\2_Folder\3_Folder\my_file.txt I would like to extract the name of the final folder and place this in a new column. ...
5
votes
2answers
16k views

Replace every nth instance of a character with a new line in Notepad++

I have a pipe delimited string of NAME|VALUE pairs looking something like this.. Name1|Value1|Name2|Value2|Name3|Value3 What I want to do is to replace every second instance of | with a new line so ...
-1
votes
2answers
51 views

Only show part of logfile in bash script

OpenVPN log looks like this: OpenVPN CLIENT LIST Updated,Sat Jun 20 04:20:07 2015 Common Name,Real Address,Bytes Received,Bytes Sent,Connected Since [ A .... ] ROUTING TABLE Virtual Address,Common ...
1
vote
1answer
125 views

Swapping / exchanging two selections in Webstorm

Is there a way of swapping two selections under multiple carets like in sublime-text in the Jetbrains' editors like Webstorm. The default shortcut in sublime text is CTRL+T for the transpose command. ...
0
votes
1answer
246 views

Excel - Look up list of substrings within large strings

I've been struggling with the following; might be a bit of a challenge. I have an Excel file that was exported from an XML application. Sheet 1 contains rows of strings like those below. Every odd-...
0
votes
0answers
475 views

Replace in file with Huge String (Argument list too long)

I have a file in which I want to replace a string with a huge string literal in the form "19209302","19209329" such 100 thousand of entries. I am using sed and I get "Argument list to long" error, ...
1
vote
4answers
2k views

Powershell parse object / string

Learning powershell, trying to find out how to parse the first value from this resultset: IPAddresses ----------- {10.60.50.40, fe80::5ddf:a8f4:e29c:b66} Normally I would just look it up, however, I ...
2
votes
1answer
59 views

Prepending a ‘.’ to each domain name in a list but skip raw IP addresses

We are starting a new proxy server at work and have a list of domains that are to be blocked; the list is downloaded from an external site. To place them in Squid format we have to add a . to the ...
1
vote
2answers
29k views

Find and replace notepad++ with wildcards

I've read about 15 tutorials on regular expression however I'm clearly not getting as I've been unable to tailor it to my problem. I have one set of code which would be found in many different ...
0
votes
2answers
2k views

Notepad++: How to trim strings to a maximum length in a huge file?

community i need your help, please! i want to trim strings in a file with about 900000 lines: KAA BSJDKWLADDKHUEW AJMJJ GMEMJRGUMGA GJWEGRJGJALUSGEUIGRL AGUGADJF WE ..... I Want to trim all ...
1
vote
3answers
346 views

How to split and distribute columns like “A,B,C” and “X,Y,Z” into “A,X,B,Y,C,Z”?

so this seems tricky to me but i have a set of data that need to be split into alternating comlumns here is what i mean is in the example below i split column A to C E and G ect depending on how many ...
1
vote
1answer
736 views

Notepad++ macro for changing a certain part of a string

I want to define a Notepad++ macro that takes any string that contains "foo", and creates its new versions only changing the foo to "bar1", "bar2" etc. so if my file contains abc_foo_def when I ...
0
votes
2answers
55 views

Remove New Line at the beginning and '-' from the contents of file

I have a file with the below output. ---------- PFIZ_EXT_SEAGRCLMHISD_20141013_1.TXT: 165428 ---------- PFIZ_EXT_SEBMODCHKIND_20141013_1.TXT: 0 ---------- PFIZ_EXT_SECNSLDND_20141013_1....
4
votes
3answers
950 views

How to find the common paths from a list of paths/files

Prelude: Given a sorted input of a list of paths/files, how to find their common paths? Translating into tech term, if feeding the sorted input from stdin, how to pick the shortest proper prefix ...
2
votes
2answers
166 views

String Manupulation in VBA

I have single column that needs to be split to multiple, like Text-to-columns in excel. However there is a small challenge. Conventional delimiter will not work. Consider the string below Original: ...
0
votes
2answers
107 views

How to find number of `_`-separated words?

I want to make a Unix command that reads a string and counts how many words it contains. In my case the words are separated by a _ (underscore) character, not spaces. For example, TABLE_PERSON ...
0
votes
1answer
1k views

how to extract last number sequence in an IP Address (using Linux)

I want to extract the last digits of an IP Address based on the result of ifconfig command. ifconfig often includes a whole heap of output so I'm not really sure how to get the digits that I want. ...
1
vote
2answers
439 views

Why doesn't grep work with single quotes?

I have a bash script wrapped in " " so I need to use ' ' for my grep command but it doesn't work. I can't switch the quotes because then the variables are not expanded. #!/bin/bash PWD=`pwd` source "...
3
votes
2answers
2k views

How can I do string manipulation in fish shell

How can I do bash style string manipulations in Fish shell? Specifically, in bash read branch < ".git/HEAD" branch=${branch#ref: refs/heads/} will put the branch name in $branch variable. How ...
0
votes
1answer
95 views

Extract part of a cell's text

I have text values in 10's of thousands of cells. I want to pull off the "prefix" and put it in a separate column. We have a delimiter, guaranteed, of a hyphen with spaces around it to help pick off ...
4
votes
1answer
5k views

How do I append dynamic number of spaces at the end of a string in a batch file

I want to output information to a log file as such 01/08/2013 14:30 - Dynamic-Machine-Name - Message starts 02/08/2013 07:12 - DynamicMachineName - Log entry 02/08/2013 07:14 - Dynamic-PC-...