Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Fobbbbbb

Name: Anonymous 2012-10-11 22:50

I want to do a regex operation on datafiles to convert decimals to Roman numerals.

I wanted to do something like

str_replace_all("blahblah02 blahblahblah03 blahblahbla05", "([0-9]{2})", convertToRomanNumeral("\\1"))

however, this replacement doesn't work...as in, the third parameter should be a string and i have given it a function


How am I supposed to do this?

Name: Anonymous 2012-10-11 22:53

regexps aren't anal touring complete

Name: Anonymous 2012-10-11 23:02

okay well then i'm gonna have this list of replacements like  this

str_replace_all("blah02 blah03 blah05", "blah01", "blahI")
str_replace_all("blah02 blah03 blah05", "blah02", "blahII")
str_replace_all("blah02 blah03 blah05", "blah03", "blahIII")
str_replace_all("blah02 blah03 blah05", "blah04", "blahIV")
str_replace_all("blah02 blah03 blah05", "blah05", "blahV")
str_replace_all("blah02 blah03 blah05", "blah06", "blahVI")
str_replace_all("blah02 blah03 blah05", "blah07", "blahVII")
str_replace_all("blah02 blah03 blah05", "blah08", "blahVII")
str_replace_all("blah02 blah03 blah05", "blah09", "blahVIII")
str_replace_all("blah02 blah03 blah05", "blah10", "blahIX")
str_replace_all("blah02 blah03 blah05", "blah11", "blahX")

up until 26 (number of chromosomes)
that's enterprise quality shit

Name: Anonymous 2012-10-11 23:09

>>3
write a function for it you cockmongling pissface

Name: Anonymous 2012-10-11 23:23

i'd rather have a fucking regex do it but whatever

Name: Anonymous 2012-10-11 23:26

I guess this will do


convertFile2<-function(filename) {
 
  filetext<-read(filename,-1)
  for(i in 1:16) {
    filetext<-str_replace_all(filetext,
      sprintf("chr%d.fsa",i), sprintf("chr%s",romanNum(i)))
  }
  filetext<-str_replace_all(filetext,  "chrmt.fsa", "chrM")
  write(filetext,filename)
 
}

Name: Anonymous 2012-10-11 23:27

>>1
Use a regex library that supports functions in the replacements, you titslapping shithead.

Name: Anonymous 2012-10-12 0:00

can I have the source code for your insult generator program

Name: Anonymous 2012-10-12 2:15

Learn Perl and stop dicking around with enterprise crap.


perl -MRoman -pe 's/(\d+)/Roman($1)/ge' file_path

Don't change these.
Name: Email:
Entire Thread Thread List