Questions tagged [text-manipulation]

Text/String manipulation is the term used to describe various operations applied to strings and/or text.

Text/String manipulation is the term used to describe various operations applied to strings and/or text. Often used with Regex or replace functions, concatination, etc.

237 questions
1
vote
1 answer

Using JQ to filter JSON data at different levels

I have this JSON data : some-json-file which contains the following { "result": [ { "id": "1234567812345678", "name": "somewebsite.com", "status": "active", "type": "secondary", "activated_on":…
madacoda
  • 363
  • 4
  • 11
1
vote
4 answers

Is there a way to search for a word in a file and save both said word and another word I know the beginning of?

I am looking for a way to filter a (~12 Gb) largefile.txt with long strings in each line for each of the words (one per line) in a queryfile.txt. But afterwards, instead of outputting/saving the whole line that each query word is found in, I'd like…
Piers
  • 21
  • 4
1
vote
1 answer

JQ: Remove empty arrays from JSON

I am having trouble deleting all empty arrays from a JSON file with jq. I've tried: walk(if type == "array" then map(select(length > 0)) else . end) which removes empty strings, but the arrays stay in the document. Is there a way to remove the…
1
vote
1 answer

Merge two txt files as columns in Windows

I need to be able to merge as separate columns files with millions of lines. I tried using the suggested code here: @echo off set f1=1.txt set f2=2.txt set outfile=mix.txt type nul>%outfile% ( for /f "delims=" %%a in (%f1%) do ( setlocal…
greektranslator
  • 499
  • 1
  • 6
  • 19
1
vote
2 answers

Concatenate CSV files and skip SECOND row

I'm using PowerShell to concatenate social media log files and Facebook, in their infinite wisdom, have added a SECOND row to their header line. I currently use this: Get-ChildItem -Filter *.csv | Select-Object -ExpandProperty FullName | Import-Csv…
John Eddy
  • 51
  • 5
1
vote
1 answer

Replace empty values based on part of the text from another variable in Pandas dataframe, using filter and regex expression

I want to replace empty values with part of the text I find in another variable in Pandas. To achieve this, I need to make use of a regex expression to extract the exact text value I want transferred, but also apply a filter so that only those rows…
Gisle_B
  • 47
  • 4
1
vote
3 answers

RegEx to replace trailing string in specific format

How can I replace these trailing "N megapixels" strings with "" using Regular Expression (RegEx.Replace)? Examples: If we enter: "Powershot Yellow 12.1 Megapixels", the result would be: "Powershot Yellow" if we enter: "Powershot Black II 10 …
Junior Mayhé
  • 16,144
  • 26
  • 115
  • 161
1
vote
2 answers

remove a certain part of a text string

I'm trying to remove some part of a string in order to isolate a value of a sentence. I would like to store the thing that is liked in a var called thingLoved. So when you type "I love cats" you can have a console.log(thingLoved) = cats In order do…
Aurore
  • 696
  • 4
  • 16
1
vote
3 answers

Javascript: how to get from textaeria filled with dots and stars get 0-1 array?

I want to create a simple javascript "life game" implementation. I want user to be capable of inputing his structures.. So we have a textaeria, user fills it with something like *··· *·*· **·· How to get from such input width 4 , height 3, and an…
Rella
  • 65,003
  • 109
  • 363
  • 636
1
vote
3 answers

Split string into array of exactly two parts when a number is encountered

Is there a way to split a string into an array of exactly two parts when a number is encountered (preferably using split())? Examples: "Nutritional Value per 100 gram" ==> ["Nutritional Value per", "100 gram"] "Protein (g) 4.27" ==> ["Protein (g)",…
A. Vasilev
  • 13
  • 2
1
vote
1 answer

Add Content Next to the line of a given search pattern in ruby

I'm making a custom rails 3 generator, I want to add some content after the attributes line in the following locale file, for example, inserting "user: 'User'" es: activerecord: attributes: user: 'User' # some stuff errors: …
fespinozacast
  • 2,484
  • 4
  • 23
  • 38
1
vote
2 answers

Problem with text formating in applescript

I have been trying to tackle a problem I am having extracting text from a website and filtering it to get the information I want. I have gotten to the point where I create a TextEdit file from the website that looks like this: 7:00 Name of Meeting:…
1
vote
0 answers

Replace a single word continuously on every page with tampermonkey

I would like to create a script that changes one word to an other in a page, works on SPAs, dynamically loaded content and in any humanly readable place: textNodes of most tags and attributes that are visible. The best I could come up with is: //…
vinczemarton
  • 7,756
  • 6
  • 54
  • 86
1
vote
1 answer

Extracting strings from binary file using regex and converting to ASCII -- Using Perl

Trying to figure out how to extract a string off characters from a binary file and convert them to ascii. The characters are a barcode, which is preceded by a constant string of text. My thought is to figure out what the HEX pattern is for the…
blunders
  • 3,619
  • 10
  • 43
  • 65
1
vote
1 answer

Is there a way to select and edit the next occurrence in a case independent (yet, respective) fashion?

Example, let's say you have the text: foo Foo foo You select the first 'foo' and perform the keyboard shortcut for 'next occurrence', ideally highlighting 'Foo' (not the second 'foo'). You then proceed to type bar on your keyboard. The text changes…