From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: hector Newsgroups: gmane.emacs.help Subject: Re: Negative Lookahead Equivalent in emacs Date: Tue, 9 May 2017 10:44:28 +0200 Message-ID: <20170509084428.GA3576@workstation> References: <49e1dd7d-4be5-4b03-b9e2-e26b15b0a6cb@googlegroups.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1494319516 12074 195.159.176.226 (9 May 2017 08:45:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 9 May 2017 08:45:16 +0000 (UTC) User-Agent: Mutt/1.5.20 (2009-06-14) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue May 09 10:45:13 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d80lY-0002uo-3M for geh-help-gnu-emacs@m.gmane.org; Tue, 09 May 2017 10:45:08 +0200 Original-Received: from localhost ([::1]:35842 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d80ld-0006eN-PQ for geh-help-gnu-emacs@m.gmane.org; Tue, 09 May 2017 04:45:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52806) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d80l2-0006dO-Iu for help-gnu-emacs@gnu.org; Tue, 09 May 2017 04:44:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d80kz-0003ed-Fo for help-gnu-emacs@gnu.org; Tue, 09 May 2017 04:44:36 -0400 Original-Received: from mail-wr0-x22f.google.com ([2a00:1450:400c:c0c::22f]:34221) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d80kz-0003ds-9Y for help-gnu-emacs@gnu.org; Tue, 09 May 2017 04:44:33 -0400 Original-Received: by mail-wr0-x22f.google.com with SMTP id l9so63603806wre.1 for ; Tue, 09 May 2017 01:44:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:subject:message-id:mail-followup-to:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=FcVhzyjgthRFlNaX1tE3eOF0EYFtVgouebIVkDt+To4=; b=FKeqirkQ64qrgHfLyzH4rYpTZHCZU+H6Xy3a54vCeeb6yqYkU/v3ic43u/9KIV+vni G83C7USc2b2ueR64Og3N5vFw31VxAfiQAuhsC6NfROA6O6n13QLNjajslPpN0SiP76Jq p76vP/7muug6fm1G45Ry7dc9eMyP6E4XQYmWfExJGcX2d50hKYYnymEG9j+nfZ4rTgTu NGcYVMFNoxMPUSSdJ1oNB35W+BdeONR/RLmxJ4D0m6ROKbQxEXpqtRJlpBMBpkCakj3u zczTTlf6iaykdlRj4Sbiu1PkNyYKK+HbuI7REI9GgbIfwPUrEpFF0ZHBKqe6fhOCtDJk tYqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:subject:message-id:mail-followup-to :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=FcVhzyjgthRFlNaX1tE3eOF0EYFtVgouebIVkDt+To4=; b=YhhXg2sKTkBnYmDf2Fdw5jbIfs/VmrPWu0ajWV+xb2VzGYGZy7zShfWfqe5QdpltoN DMfku1T0L+QU83teBpKbj5jsiQOOhSp5SQHtREJxj5soaxlw86IhTkoK9bbllL62asrd JaoENsKsKIjBZTPCgI7QgWW5X5gFo0IJGIeh2fKF9f8dofk2L7MoWHESeEyAa6WScECw pkQGwyiySWGHGALoyGKPiU9cIc1QTesUDFDbtHd+AUlcQ2gzNlnvXyVnd+/1mYYQmx8u RgWB2aMAcAMizlF3TWYIDp/9DK4DBfpRhWS1OxJXlPrRCkGjzvCdt6WTT6G0d9jeZ5hM JwQw== X-Gm-Message-State: AN3rC/6qB5jLU/J0Jo1xGZhgGAgqTb0vp0HztqXE1aV32O+TtEadkIjX SYjy4GsCAPcfah+I X-Received: by 10.223.133.35 with SMTP id 32mr17503720wrh.200.1494319471704; Tue, 09 May 2017 01:44:31 -0700 (PDT) Original-Received: from workstation ([148.56.209.77]) by smtp.gmail.com with ESMTPSA id y60sm20210897wrb.39.2017.05.09.01.44.30 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 09 May 2017 01:44:31 -0700 (PDT) X-Google-Original-From: hector Mail-Followup-To: help-gnu-emacs@gnu.org Content-Disposition: inline In-Reply-To: <49e1dd7d-4be5-4b03-b9e2-e26b15b0a6cb@googlegroups.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::22f X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:112975 Archived-At: On Mon, May 08, 2017 at 10:15:42PM -0700, luishenriquezperez@gmail.com wrote: > Hi, > > I'm trying to write a regex that matches the last character of a sequence of non-whitespace characters '[^\n\r\t\f ]', or an empty line matching ^$. > > Thus: > Hello World! --> "o" and "!" would be matched > > In non-elisp regex languages I know the code for this is: \S(?!\S) > I know that \S is equivalent too [^ /n/r/t/f]. > But I'm unsure of what the elisp equivalent (if any) of the negative lookahead (?!). > > I saw on this forum a post "gnu.emacs.help › regex nirvana - near miss" > Where Drew Adams said: "Typically, what you want to do for this in Emacs Lisp is to combine > the use of a regexp for positive matching with other code that takes > care of the non-matching (negation) need. " > > However, I'm not sure how to go about doing this. Perhaps \\S-\\s- or [^[:space:]][[:space:]] not including the ^$. I guess you just had to add "\\|^$" to the preceding expressions. I'm not sure if there is any difference between the two syntaxes. Note that these expressions depend on the syntax table. So the definition of "[[:space:]]" can change depending on syntax table. It is not necessarily "[\n\t\f\r\v ]"