[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
grep/sed
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 5
Thread images: 2
File: 1466732852437.jpg (4 KB, 238x195) Image search: [Google]
1466732852437.jpg
4 KB, 238x195
I'm so sick and fucking tired of the shitty sed and grep regex syntax. So i'm sharing a piece of Java code.

import java.io.*;
import java.util.regex.*;

public class Jsed{

public static void main (String args[]) {

Pattern p = Pattern.compile(args[0]);

try {

InputStream in = System.in;
ByteArrayOutputStream out = new ByteArrayOutputStream();

byte[] buf = new byte[4096];
int b;

while ((b = in.read(buf)) != -1) {
out.write(buf, 0,b);
}

Matcher m = p.matcher(new String(out.toByteArray()));

while (m.find()) {
System.out.println(m.group(1));
}

} catch(IOException io){
io.printStackTrace();
}
}
}


This enables you to use Java's Regex system in a pipe. For ex.

thinkpad :: ~/Documents % tree -if | jsed "(.*\d+_\d+_\d+.*\.jpg)"
./instagram/122252_161113958834_185772_n.jpg
./instagram/108184_164011148759_1532867_n.jpg
./instagram/122913_163463958699_13906354_o.jpg
./instagram/130322_151904900462_226310_n.jpg


Thank me later.
>>
Stealing this and posting on my git claiming I made it.

Thanks for the job OP!
>>
>>55481930
>adding java to your portfolio
You love being unemployed, don't you?
>>
File: IMG-20160703-WA0006.jpg (51 KB, 750x729) Image search: [Google]
IMG-20160703-WA0006.jpg
51 KB, 750x729
This is pretty cool op
>>
>>55481960

>implying java isn't the most in demand language

nice b8 m8.
Thread replies: 5
Thread images: 2

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.