Re: Quickie - Regexp for a string not at the beginning of the line
Thanks everyone, esp this gentleman. The solution that worked best for me is just to use a DOT before the string as the one at the beginning of the line did not have any char before it. I guess, this requires the ability to ignore the CARAT as the beginning of the line. I am a satisfied custormer. No need for returns. :) On Oct 25, 7:11 pm, Ben Bacarisse wrote: > Rivka Miller writes: > > On Oct 25, 2:27 pm, Danny wrote: > >> Why you just don't give us the string/input, say a line or two, and > >> what you want off of it, so we can tell better what to suggest > > > no one has really helped yet. > > Really? I was going to reply but then I saw Janis had given you the > answer. If it's not the answer, you should just reply saying what it is > that's wrong with it. > > > I want to search and modify. > > Ah. That was missing from the original post. You can't expect people > to help with questions that weren't asked! To replace you will usually > have to capture the single preceding character. E.g. in sed: > > sed -e 's/\(.\)$hello\$/\1XXX/' > > but some RE engines (Perl's, for example) allow you specify zero-width > assertions. You could, in Perl, write > > s/(?<=.)\$hello\$/XXX/ > > without having to capture whatever preceded the target string. But > since Perl also has negative zero-width look-behind you can code your > request even more directly: > > s/(? > > I dont wanna be tied to a specific language etc so I just want a > > regexp and as many versions as possible. Maybe I should try in emacs > > and so I am now posting to emacs groups also, although javascript has > > rich set of regexp facilities. > > You can't always have a universal solution because different PE > implementations have different syntax and semantics, but you should be > able to translate Janis's solution of matching *something* before your > target into every RE implementation around. > > > examples > > > $hello$ should not be selected but > > not hello but all of the $hello$ and $hello$ ... $hello$ each one > > selected > > I have taken your $s to be literal. That's not 100 obvious since $ is a > common (universal?) RE meta-character. > > > -- > Ben. -- http://mail.python.org/mailman/listinfo/python-list
Re: Quickie - Regexp for a string not at the beginning of the line
On Oct 25, 2:27 pm, Danny wrote: > Why you just don't give us the string/input, say a line or two, and what you > want off of it, so we can tell better what to suggest no one has really helped yet. I want to search and modify. I dont wanna be tied to a specific language etc so I just want a regexp and as many versions as possible. Maybe I should try in emacs and so I am now posting to emacs groups also, although javascript has rich set of regexp facilities. examples $hello$ should not be selected but not hello but all of the $hello$ and $hello$ ... $hello$ each one selected = original post = Hello Programmers, I am looking for a regexp for a string not at the beginning of the line. For example, I want to find $hello$ that does not occur at the beginning of the string, ie all $hello$ that exclude ^$hello$. In addition, if you have a more difficult problem along the same lines, I would appreciate it. For a single character, eg < not at the beginning of the line, it is easier, ie ^[^<]+< but I cant use the same method for more than one character string as permutation is present and probably for more than one occurrence, greedy or non-greedy version of [^<]+ would pick first or last but not the middle ones, unless I break the line as I go and use the non- greedy version of +. I do have the non-greedy version available, but what if I didnt? If you cannot solve the problem completely, just give me a quick solution with the first non beginning of the line and I will go from there as I need it in a hurry. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Quickie - Regexp for a string not at the beginning of the line
Hello Programmers, I am looking for a regexp for a string not at the beginning of the line. For example, I want to find $hello$ that does not occur at the beginning of the string, ie all $hello$ that exclude ^$hello$. In addition, if you have a more difficult problem along the same lines, I would appreciate it. For a single character, eg < not at the beginning of the line, it is easier, ie ^[^<]+< but I cant use the same method for more than one character string as permutation is present and probably for more than one occurrence, greedy or non-greedy version of [^<]+ would pick first or last but not the middle ones, unless I break the line as I go and use the non- greedy version of +. I do have the non-greedy version available, but what if I didnt? If you cannot solve the problem completely, just give me a quick solution with the first non beginning of the line and I will go from there as I need it in a hurry. Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: C interpreter in Lisp/scheme/python
On Jun 13, 4:07 pm, bolega wrote: > I am trying to compare LISP/Scheme/Python for their expressiveness. > > For this, I propose a vanilla C interpreter. I have seen a book which > writes C interpreter in C. > > The criteria would be the small size and high readability of the code. > > Are there already answers anywhere ? > > How would a gury approach such a project ? > > Bolega You should probably narrow down your project to one. For example, write a LISt Processor Meta Circular Evaluator in C. You can take Paul Graham's rendition as a start and forget about garbage collection. Start with getchar()/putchar() for I/O. Although C comes with a regex library, you probably do not need a regex or parser at all for this. This is the beauty of LISP which is why McCarthy was able to bypass the several man years of effort involved in FORmula TRANslator. Even as a young boy like L. Peter Deutsch was able to write it in assembly for one of the PDP's. You will have go implement an associative array or a symbol-value table probably as a stack or linked list. You will have to decide how you implement the trees, as cons cells or some other method. Dynamic scoping is easy to implement and that is what elisp has. I am not aware of any book that provides implementation of LISP in C and explains it at the same time. This is the extent of help I can provide, someone else can probably help you more. Anyone know what the first initial of L. Peter Deutsch stand for ? Rivka -- http://mail.python.org/mailman/listinfo/python-list