New answers tagged

0

By LOWER function, you can search case insensitively your string. DELETE FROM mytable WHERE LOWER(title) LIKE '%it is a sunny day%';


0

You're part way there. You need to use a regexp pattern, not just a string, to search only a part of the entry string, and the ILIKE keyword for case insensitivity. See https://www.postgresql.org/docs/9.0/static/functions-matching.html for details (that URL valid only for 9.x versions of PostgreSQL).


0

I don't think there is any nice way to do it with just one replacement. But if four replacements are fine, proceed as follows: Replace \A' by  (that is, replace ' at the beginning of the string). Replace '\Z by  (that is, replace ' at the end of the string). Globally replace ([^[:alnum:]])' by \1 (that is, replace every sequence of a ...


3

With awk it's as simple as awk -F, -vOFS=, '{$1=n++; print}' n=800 file You set the input and output delimiters to , via -F, and -vOFS=, and initialize a variable n to 800 using n=800. The "action" statement {$1=n++; print} executes for each record, setting the first field to a post-incrementing n and printing the reconstituted record


1

Replacing with Grep You can do (most of) this with regular expression search/replace. Use the Replace dialog, making sure that "Use Regular Expressions" is selected and "Use multi-line matching" is not. Search for: \\stylea{(.*)} And replace with: \1 This is a regular expression "back reference" to the "captured" text in the search expression (the ...


1

You don't need to get the database name, there's no point in replacing something with itself. Just leave it unchanged: beg="mysqli_connect(" new="'localhost','root','pass'," sed "s/$beg\([^,]\+,\)\{3\}/$beg$new/" file If I save the example you gave as file, that returns: $ sed "s/$beg\([^,]\+,\)\{3\}/$beg$new/" file sadnkjnadsjknfaskdjfnlasdnfkdsa ...


2

No one has said it yet, so I will. PLEASE don't parse XML using regular expressions. XML is a contextual language, and regular expressions aren't. This means you create brittle code, that one day might just break messily. For more examples, see: http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags PLEASE use a ...


0

Given nonancient GNU awk (gawk) and assuming each pair of testname and enabled are on the same line separate from any other pair (which is not a given for XML in general): awk 'match($0,/ testname="([^"]+)"/,a) {sub(/ enabled="[^"]+"/, " enabled=\"" (a[1]~/AA/?"true":"false") "\"")} 1' <input Explanation: match($0,/ testname="([^"]+)"/,a) returns ...


0

If I understood the logic correctly, this sed command searches for the given $1 parameter inside of the testname value; if it's present, then search and replace the enabled value from false to true. If it's not (!) present, then replace the enabled value from true to false. sed '/ testname="[^"]*'$1'[^"]*"/ s/ enabled="false"/ enabled="true"/; / ...


-1

Sorry, try this: cat xml | sed 's/\(testname\=\".*AA.*\"\s\)enabled="\(true\|false\)"/\1enabled=\"true\"/gi'


0

First create a sed script from those two files: paste -d$'\t' find.csv replace.csv | sed -e 's:/:\\/:g; s:\t:/:; s:^:s/:; s:$:/g;:' > myscript.sed That will replace all occurrences of strings in find.csv with the strings in replace.csv. It will fail if any of the lines in find.csv contain a tab character, as that is being used by paste as the ...


1

Use the following code for replacing the "dots" :%s/\./_/g <ENTER> Here "_" is replaced word.



Top 50 recent answers are included