Posts by JJoao • 5,113 points
222 posts
-
1
votes2
answers116
viewsA: Format columns - select specific information
@Qmechanic73: ... glorious Perl perl -nE 'say m/(\S+ ).*? (SIFT=\S+)/' foo.txt And by the way sed for a change sed -r 's!(\S+).*(SIFT=\S+).*!\1 \2!' foo.txt…
-
15
votes5
answers2736
viewsA: Test whether all characters of the first string also appear in the second
As referred to by @mgibsonbr, the C convention is 0 for false, not zero for true. Using this convention, I would simply: ... return (strspn(s,aceitar) == strlen(s)); Edit: Summary explanation:…
-
0
votes2
answers152
viewsA: Permutations and files
The proposal I am putting changes the question somewhat: Simplify the script to only generate permutations of the received length via the command line, sending to the stdout. Operating system splits…
-
3
votes4
answers199
viewsA: Problem accessing array element
Using flex (flex generates C and is optimal for programming textual processing) : %option noyywrap %% [a-z]{4,} { yyleng=4 ; ECHO; } .|\n { ECHO; } // (desnecessário: ação default) %% int main(){…
-
1
votes2
answers269
viewsA: Program always returns the same result in C
@mgibsonbr has said it all. The code below serves only to highlight the (questionable) importance of vertical symmetries in code indentation. #include <stdio.h> #define clearbuff…
-
3
votes2
answers260
viewsA: Doubt about pointers
With matrices (two-dimensional arrays) there are some subtilizas: int a[10][10] a contiguous memory area of 100 integers is reserved. And when you use a[2][2] ends up being transformed internally…
-
1
votes1
answer96
viewsA: Problem with Regular Expression
I didn’t fully understand what was being asked. Below is an example: extraction of some parts (xml attributes) replacement of a value (value) by a new value. based on your example <?php…
-
3
votes3
answers1729
viewsA: Regex to find occurrences of one word before the other
If the intention is to find the list of files containing that pattern suggested: grep -zPl 'TdxBar(.|\n)*TAction' * -z The -z (null separated Records) option causes the file to be loaded as if it…
-
1
votes3
answers302
viewsA: How to separate a file with multiple FASTA into different variables
(I know this question is old, but it is so rare different things of html and js that I do not resist...) #!/usr/bin/perl use strict; sub ler_fasta { my $file=shift; local $/="'>'"; # separador de…
-
4
votes1
answer962
viewsA: Bibliographic reference in Latex
I tried your Bibtex and it worked well. \documentclass[portuges,a4paper]{article} \usepackage{babel} \usepackage[utf8]{inputenc} \begin{document} \cite{Ziviani} \bibliographystyle{alpha} % ou plain…
-
7
votes5
answers9524
viewsA: Receive an expression and calculate in C
Solution based on popen Okay, okay, I admit it’s a little cheating. But since this question was asked last year, no one will notice :-) #include <stdio.h> int main(){ char s[100],com[100];…
-
1
votes2
answers9446
viewsA: Exercise of family tree
To make it simple, I’m going to skip the male/female issues. It is advisable to avoid: all be brothers to themselves parents are their children’s uncles To that end I added a condition X ≠ Y in this…
-
1
votes2
answers934
viewsA: How to create an index file using B+ tree
B+ trees are designed to work on disk. The typical use of B+ trees includes the possibility of a huge number of keys (e.g. millions), typically having all the nodes in a file and only being loaded…
-
1
votes1
answer650
viewsA: Parse XML with Shell Script
Your example is not well-formed XML... To process XML you should use a tool that includes an XML parser. For line command I would suggest something with xmllint or xmlstarlet (there are other…
-
6
votes2
answers1152
viewsA: How to count words from a string ignoring prepositions?
Slightly unixeira version... xmllint --xpath '//description' 'http://.../news.rss' | grep -Po '(*UTF8)(*UCP)\b[\w\d_][\w\d_\-.*#]*[\w\d_]\b|\w|\.\.\.|[,.:;()[\]?!]|\S' | grep ... | sort | uniq -c |…
-
0
votes2
answers262
views -
0
votes4
answers1398
viewsA: Tool to generate Xpath
Install xmllint (tiny tool, usually already installed on linux) and it’s time to practice xpath: xmllint --xpath '//symbol' file.xml or, in the case of html: xmllint --html --xpath '//table'…
-
10
votes5
answers3496
viewsA: What are the main advantages and disadvantages of using an LL parser or an LR?
Any notes on this question and the answers: Note 1: The top-down/LL techniques are being handled slightly unfairly: Usually Top-Down tools accept EBNF grammars (they are easy to implement in TD).…
-
3
votes2
answers1341
viewsA: Format echo time number with 'k', 'kk', and so on
I’ve never written anything in php, so it’s unlikely that it will work... function reduz($n) { $n=floor($n); if ($n < 1000) return $n; if ($n%1000 < 500) return reduz( $n/1000). "k" if…
-
1
votes1
answer93
viewsA: Modify VIM cursor by running on Console2
In general I came to show the mode is connected to :set showmode For details :help showmode can be set in configuration file ($HOME/. vimrc in Unix, $HOME/_vimrc in windows)…
-
1
votes3
answers474
viewsA: Getting Output Terminal History on Ubuntu
Output from a terminal: H1) define a long terminal history, and cut&paste the terminal to a file H2) use command script file (keeps the session in file) -- script has several options that may be…
-
4
votes8
answers5853
viewsA: Recognize word repeats in String
Okay, okay, okay, it’s not Java... #!/usr/bin/perl use strict; use utf8::all; my %conta; my $s="Hoje em dia, é necessário ser esperto. O nosso dia a dia é complicado."; for($s=~ m{(\w+)}g ) {…