I have a class that is doing a lot of text processing. For each string, which is anywhere from 100->2000 characters long, I am performing 30 different string replacements.
Example:
string modified;
for(int i = 0; i < num_strings; i++){
modified = runReplacements(strs[i]);
//do stuff
}
public runReplacements(String str){
str = str....
Hi!
I have appender like this.
<appender name="Action.FileAppender" class="ch.qos.logback.core.FileAppender">
<file>logs\\${date}\\${thread}.log</file>
<encoder>
<pattern>%level - %msg%n</pattern>
</encoder>
</appender>
And i want to ${date} and ${thread} be current date and current thread name. How i can do it?
...
Hi,
I am working on this application for which we have to write framework services like reporting, logging, exception handling, security. Since these services are are to be used through the project, i am thinking of exposing the instances of these services through a service container which has reference to the objects of these individual...
Hello all
I need to get some users from LDAP, only those that belong to groups whose names begin with a pattern, something like this
((&objectcategory=user)(memberof=cn=**groupNamePattern_***,OU=distribution,DC=xx,DC=com))
I think it needs to do some sort of sub-query, so that it first retrieves the list of groups that match the patt...
Hi,
I'm writing some code to do some stuff and I'm pretty sure its not well designed at the moment but I can't think how I should be refactoring it to make it nicer...
The simple summary is that I have some code which goes through some files in a directory structure and different directories contain different content types. I have a li...
A date can be formatted using a e.g. SimpleDateFormat(formatPattern, locale).
Is it somehow possible to determine the time period (in seconds) that is represented by formatPattern given a date? E.g. if we have
Date date = new Date(1286488800);
String formatPattern = "yyyy";
is it possible to determine the length of the year (in second...
Hi all, my homework assignment was to: "write a function called findPattern() which accepts two strings as parameters, a filename and a pattern. The function reads in the file specified by the given filename and searches the file’s contents for the given pattern. It then returns the line number and index of the line where the first inst...
Hello there, I got a generic repository - should the repository be able to throw exceptions or should I keep it dumb? If I chose to throw exceptions from it, should the service layer then catch it and throw an exception with a more friendly message before it goes to the Controller?
Pos1: Repository (Throw) => Service(Catch, Throw new) ...
I am using a while(matcher.find()) to loop through all of the matches of a Pattern. For each instance or match of that pattern it finds, I want to replace matcher.group(3) with some new text. This text will be different for each one so I am using matcher.appendReplacement() to rebuild the original string with the new changes as it goes...
For example,
The string is: "{{aaa,bbb},{ccc,ddd},{eee,fff}}"
I want the program auto split it as a string pattern
Pattern is: {{...},{...},{...}}
What is the Pattern Matching regex?
...
I am looking into how to write a paint program that supports undo and seeing that, most likely, a command pattern is what I want. Something still escapes me, though, and I'm hoping someone can provide a simple answer or confirmation.
Basically, if I am to embody the ability to undo a command, for instance stamping a solid circle on the...
Hi ,
it's a week i'm trying to find an answer for my question , i would appreciate if anyone can help .
I've got a list of strings(originally list of sequences which can be viewed as list of strings) and i'd like to find a pattern (which is a string itself) withtin strings of this list , is there any java library which can i use or is t...
Can I do something like this in Perl? Meaning pattern match on a file name and check whether it exists.
if(-e "*.file")
{
<Do something>
}
I know the longer solution of asking system to list the files present; read it as a file and then infer whether file exists or not.
...
Hi,
I would like to have a Bean and a SubBean like this:
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
@Component
public class SubBean implements ApplicationContextAware{
private Object parent;
public void setApplicationContext(ApplicationContext ctx){
this.parent = doSomeMagicToGetMyParent(ctx);
}
public Object getParent(){
...
Im trying to check a file line by line for any_string=any_string. It must be that format, no spaces or anything else. The line must contain a string then a "=" and then another string and nothing else. Could someone help me with the syntax in python to find this please? =]
pattern='*\S\=\S*'
I have this, but im pretty sure its wrong h...
Im searching a file line by line for the occurrence of ##random_string##. It works except for the case of multiple #...
pattern='##(.*?)##'
prog=re.compile(pattern)
string='lala ###hey## there'
result=prog.search(string)
print re.sub(result.group(1), 'FOUND', string)
Desired Output:
"lala #FOUND there"
Instead I get the following...
Possible Duplicate:
Python Regular Expression Matching: ## ##
I already asked this question, but let me restate it better... Im searching a file line by line for the occurrence of ##random_string##. It works except for the case of multiple #...
pattern='##(.*?)##'
prog=re.compile(pattern)
string='lala ###hey## there'
result=...
In the past I used Sub Sonic which has the activerecord pattern baked into the framework. With Sub Sonic it was very easy to find the "dirty" fields on an update. I now have a need to create an audit table in my application that utilizes Entity Framework 4. Is there a comparable feature in EF 4 that will give me the dirty fields?
Thank...
Hello,
I have this for:
for i in `ls -1 access.log*`; do tail $i |awk {'print $4'} |cut -d: -f 1 |grep - $i > $i.output; done
ls will give access.log, access.log.1, access.log.2 etc.
tail will give me the last line of each file, which looks like: 192.168.1.23 - - [08/Oct/2010:14:05:04 +0300] etc. etc. etc
awk+cut will extract the dat...
I am searching for ideas/examples on how to store path patterns from users - with the goal of analysing their behaviours and optimizing on "most used path" when we can detect them somehow.
Eg. which action do they do after what, so that we later on can check to see if certain actions are done over and over again - therefore developing a...