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

grep/sed

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 5
Thread images: 2

File: 1466732852437.jpg (4KB, 238x195px) Image search: [Google]
1466732852437.jpg
4KB, 238x195px
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 (51KB, 750x729px) Image search: [Google]
IMG-20160703-WA0006.jpg
51KB, 750x729px
This is pretty cool op
>>
>>55481960

>implying java isn't the most in demand language

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


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.