Bug 80453 - support for non-greedy matching
Summary: support for non-greedy matching
Status: RESOLVED FIXED
Alias: None
Product: kregexpeditor
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Debian testing Linux
: NOR wishlist
Target Milestone: ---
Assignee: Jesper Pedersen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-27 07:57 UTC by Stian Haklev
Modified: 2006-08-23 12:03 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stian Haklev 2004-04-27 07:57:45 UTC
Version:            (using KDE KDE 3.2.2)
Installed from:    Debian testing/unstable Packages
OS:          Linux

If there is a way of enabling this in Kregexpeditor I haven't found it, though looking in the documentation and on the net - there should be a checkbox or a control or something for non-greedy matching. I think a lot of kwrite users would need such a thing, for example replacing all < xxx > in a document with "" (taking out HTML tags) etc etc.

If this exists, then make it more obvious.

Otherwise, a really great product! Beautiful!

Stian
Comment 1 Nick Leverton 2005-02-17 03:12:15 UTC
I'd like to extend this one to a plea to support perl REs.  Although I understand kregexpeditor was built for qt's REs, the menu already offers emacs REs.  Building/testing perl REs too, with assertions and non-greedy matches, would be teriffic.
Comment 2 Nick Leverton 2005-02-17 03:14:07 UTC
*** This bug has been confirmed by popular vote. ***
Comment 3 Bram Schoenmakers 2005-08-13 12:47:33 UTC
SVN commit 448854 by bram:

o GUI option created for greedy regexp matching (80453)
o Accellerator added to ASCII edit field.

FEATURE: 80453



 M  +11 -2     kregexpeditorprivate.cpp  
 M  +2 -0      kregexpeditorprivate.h  
 M  +8 -0      verifybuttons.cpp  
 M  +1 -0      verifybuttons.h  


--- trunk/KDE/kdeutils/kregexpeditor/kregexpeditorprivate.cpp #448853:448854
@@ -55,7 +55,7 @@
 
 
 KRegExpEditorPrivate::KRegExpEditorPrivate(QWidget *parent, const char *name)
-    : QWidget(parent, name), _updating( false ), _autoVerify( true )
+    : QWidget(parent, name), _updating( false ), _autoVerify( true ), _matchGreedy( false )
 {
   setMinimumSize(730,300);
   Q3DockArea* area = new Q3DockArea( Qt::Horizontal, Q3DockArea::Normal, this );
@@ -132,6 +132,7 @@
   connect( _verifyButtons, SIGNAL( autoVerify( bool ) ), this, SLOT( setAutoVerify( bool ) ) );
   connect( _verifyButtons, SIGNAL( verify() ), this, SLOT( doVerify() ) );
   connect( _verifyButtons, SIGNAL( changeSyntax( const QString& ) ), this, SLOT( setSyntax( const QString& ) ) );
+  connect( _verifyButtons, SIGNAL( matchGreedy( bool ) ), this, SLOT( setMatchGreedy( bool ) ) );
 
   connect( this, SIGNAL( canUndo( bool ) ), _auxButtons, SLOT( slotCanUndo( bool ) ) );
   connect( this, SIGNAL( canRedo( bool ) ), _auxButtons, SLOT( slotCanRedo( bool ) ) );
@@ -163,7 +164,7 @@
 
   // Line Edit
   QHBoxLayout* layout = new QHBoxLayout( topLayout, 6 );
-  QLabel* label = new QLabel( i18n("ASCII syntax:"), this );
+  QLabel* label = new QLabel( i18n("ASCII synta&x:"), this );
   layout->addWidget( label );
   clearButton = new QToolButton( this );
   const QString icon( QString::fromLatin1( QApplication::reverseLayout() ? "clear_left" : "locationbar_erase" ) );
@@ -172,6 +173,7 @@
   layout->addWidget( clearButton );
   QToolTip::add( clearButton, i18n("Clear expression") );
   _regexpEdit = new QLineEdit( this );
+  label->setBuddy( _regexpEdit );
   layout->addWidget( _regexpEdit );
   _regexpEdit->setWhatsThis( i18n( "This is the regular expression in ASCII syntax. You are likely only "
 				      "to be interested in this if you are a programmer, and need to "
@@ -430,3 +432,10 @@
 {
     _verifyButtons->setAllowNonQtSyntax( b );
 }
+
+void KRegExpEditorPrivate::setMatchGreedy( bool b )
+{
+  _matchGreedy = b;
+  _verifier->setMinimal( !b );
+  doVerify();
+}
--- trunk/KDE/kdeutils/kregexpeditor/kregexpeditorprivate.h #448853:448854
@@ -64,6 +64,7 @@
     void doVerify();
     void setAutoVerify( bool );
     void setVerifyText( const QString& fileName );
+    void setMatchGreedy( bool );
 
 public slots:
     void slotUndo();
@@ -100,6 +101,7 @@
     bool _autoVerify;
     ErrorMap _errorMap;
     QToolButton *clearButton;
+    bool _matchGreedy;
 };
 
 #endif
--- trunk/KDE/kdeutils/kregexpeditor/verifybuttons.cpp #448853:448854
@@ -129,6 +129,14 @@
                                     "If the verify window contains much text, or if the regular expression is either "
                                     "complex or matches a lot of time, this may be very slow."));
 
+    QAction* matchGreedy = new QAction( i18n("Match Greedy"), 0, this );
+    matchGreedy->setToggleAction( true );
+    matchGreedy->setOn( false );
+    connect( matchGreedy, SIGNAL( toggled( bool ) ), this, SIGNAL( matchGreedy( bool ) ) );
+    matchGreedy->addTo( _configMenu );
+    matchGreedy->setToolTip( i18n("Toggle greedy matching when verifying the regular expression.") );
+    matchGreedy->setWhatsThis( i18n( "When this option is enabled, the regular expression will be evaluated on a so-called greedy way." ) );
+
     // RegExp Languages
     Q3PopupMenu* languages = new Q3PopupMenu( _configMenu );
     _languageId = _configMenu->insertItem( i18n("RegExp Language"), languages );
--- trunk/KDE/kdeutils/kregexpeditor/verifybuttons.h #448853:448854
@@ -42,6 +42,7 @@
     void verify();
     void autoVerify( bool );
     void loadVerifyText( const QString& );
+    void matchGreedy( bool );
 
     // Qt anchors do not work for <pre>...</pre>, thefore scrolling to next/prev match
     // do not work. Enable this when they work.
Comment 4 Bram Schoenmakers 2005-08-13 12:54:37 UTC
Nick: You should have submitted a separate bug report for that. The original wish is fulfilled, but your wish isn't. If you submit a new bug report, we won't forget about it.
Comment 5 Andreas Sigg 2006-08-23 12:00:45 UTC
I'm running KDE 3.5.1 Level a, but this feature is still not implemented in kregexpeditor. When do we get the feature?
Comment 6 Andreas Sigg 2006-08-23 12:03:00 UTC
When I click on the help-button of kregexpeditor, the handbook opens and shows the following version:

Version 0.1 (2001-07-03)