473,386 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Skip and pass part of each line in selected text

1
Hi everybody,

Currently I am working on an function in which I want to tag certain parts of text.

This is what I have now :

Expand|Select|Wrap|Line Numbers
  1.       case "djenter":
  2.     var selection = str;
  3.         if(selection){
  4.     selection = selection.replace(/  /gi, ' ');
  5.     selection = selection.replace(/\n/gi,']\n[dj=');
  6.     selection = selection.replace(/\f/gi,']');
  7.     selection = selection.replace(/\r/gi,']');
  8.     selection = selection.replace(/\)\]/gi, '\)');
  9.     selection = selection.replace(/ \(/gi, '\] \(');
  10.     selection = selection.replace(/ \]/gi, '\]');
  11.     selection = selection.replace(/\[dj=hosted by /gi, "Hosted by [dj=").replace(/\[dj=live : /gi, "LIVE : [dj=").replace(/\[dj=live /gi, "LIVE [dj=").replace(/\ vs. /gi, "] vs. [dj=").replace(/\ vs /gi, "] vs [dj=").replace(/\ aka /gi, "] aka [dj=").replace(/\ \& /gi, "] \& [dj=").replace(/\[dj=dj /gi, "dj [dj=").replace(/\[dj=mc /gi, "mc [dj=").replace(/\ live]/gi, "] LIVE");
  12.         bbcode.insertAtCursorEx("[dj=" + selection,"]",select_flag);
  13.     }else{
  14.         alert("Je dient wel eerst een selectie te maken van DJ's welke geslitst worden doormiddel van een ENTER");
  15.     }
  16.         break;
The above will tag a for example the following text :

------------------------
Reload-R & D-Ablo
Masochist & Re-Style
D-Spirit & Sceletor
The Viper & Partyraiser
J:D:A:
Evil Activities
Paul Elstak & MC Ruffian
Endymion & Nosferatu
Dione & Headbanger
Angerfist
Tommyknocker & Bike
Outblast & Catscan
Vinyl Junk
Vince
------------------------

Into the following :

------------------------
[dj=Reload-R] & [dj=D-Ablo]
[dj=Masochist] & [dj=Re-Style]
[dj=D-Spirit] & [dj=Sceletor]
[dj=The Viper] & [dj=Partyraiser]
[dj=J:D:A:]
[dj=Evil Activities]
[dj=Paul Elstak] & mc [dj=Ruffian]
[dj=Endymion] & [dj=Nosferatu]
[dj=Dione] & [dj=Headbanger]
[dj=Angerfist]
[dj=Tommyknocker] & [dj=Bike]
[dj=Outblast] & [dj=Catscan]
[dj=Vinyl Junk]
[dj=Vince]
------------------------

The above works fine, but I would like it also to be possible to let the function beable to exclude the time values in the example below :

22:00 – 22:45 Reload-R & D-Ablo
22:45 – 23:30 Masochist & Re-Style
23:30 – 00:15 D-Spirit & Sceletor
00:15 – 01:00 The Viper & Partyraiser
01:00 – 01:30 J:D:A:
01:30 – 02:15 Evil Activities
02:15 – 03:00 Paul Elstak & MC Ruffian
03:00 – 03:45 Endymion & Nosferatu
03:45 – 04:30 Dione & Headbanger
04:30 – 05:00 Angerfist
05:00 – 05:45 Tommyknocker & Bike
05:45 – 06:30 Outblast & Catscan
06:30 – 07:15 Vinyl Junk
07:15 – 08:00 Vince

So the time values are ignored and only the names after the times are tagged the same way as given in the first example.

If tried different ways using the \d{2}\:\d{2} - \d{2}\:\d{2}/gi method but can't seem to get it to work.

Can anybody help me on my way?

Kind regards and thanks in advance!
Jun 17 '07 #1
1 1583
gits
5,390 Expert Mod 4TB
hi ...

did you miss the opening slash / ? the following works, so your regEx should work too:

Expand|Select|Wrap|Line Numbers
  1. var check = /\d{2}\:\d{2} - \d{2}\:\d{2}/gi.test('12:23 - 14:34 test');
  2.  
  3. // check is true ;)
  4.  
the two slashes are required until these are the literals to create a valid regEx ...

kind regards
Jun 17 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: StvB | last post by:
Hi, I have a wxPython app which dump errors when I close it ( in the debug output at bottom of Komodo, when I close my app. ) Where I got the code for my GUI: Straight from the wxProject.py...
4
by: Dan | last post by:
Can anyone offer suggestions on how to do this or if it is possible? I have a form that uses a drop down box and 2 text fields. What I am trying to do is have the value of each text box set by...
9
by: Alan Silver | last post by:
Hello, I'm a bit surprised at the amount of boilerplate code required to do standard data access in .NET and was looking for a way to improve matters. In Classic ASP, I used to have a common...
0
by: clintonG | last post by:
I applied aspnet_regsql to SQL2K which was working fine throughout Beta 2 development. After installing Visual Studio and SQL Express RTM my application has blown up. Logging in to the application...
16
by: Adam Witney | last post by:
Hi, Is it possible for the COPY command to read data from a file, but skip specific columns? Thanks Adam
6
by: kath | last post by:
hi everyone......... I have a task, I have fragmented the task into subtask. I have planned to create a class to each subclass and one parent class to handle the sub tasks. Each subclass are...
19
Atli
by: Atli | last post by:
Introduction At some point, all web developers will need to collect data from their users. In a dynamic web page, everything revolves around the users input, so knowing how to ask for and collect...
6
by: John Wright | last post by:
I am trying to read the data from a device on a serial port. I connect just fine and can receive data fine in text mode but not in binary mode. In text mode the data from the device comes in...
3
by: blunt | last post by:
right the program is nearly complete just a couple of little tweaks and i should have it. The purpose of this program is to write config files for colubrius wireless access points but it's falling...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.