Click here to Skip to main content
16,020,706 members
Home / Discussions / Regular Expressions
   

Regular Expressions

 
GeneralRe: Finding a specific number in a string. Pin
Member 1086910715-Aug-20 1:17
Member 1086910715-Aug-20 1:17 
QuestionHow to skip a particular term in regex find and replace? Pin
usernamekiran11-Aug-20 4:34
usernamekiran11-Aug-20 4:34 
AnswerRe: How to skip a particular term in regex find and replace? Pin
Gerry Schmitz11-Aug-20 6:39
mveGerry Schmitz11-Aug-20 6:39 
QuestionFind Sequence of alphabets in the string Pin
arisaravanan11-Apr-20 1:32
arisaravanan11-Apr-20 1:32 
AnswerRe: Find Sequence of alphabets in the string Pin
Richard MacCutchan11-Apr-20 4:21
mveRichard MacCutchan11-Apr-20 4:21 
AnswerRe: Find Sequence of alphabets in the string Pin
Richard Deeming14-Apr-20 0:30
mveRichard Deeming14-Apr-20 0:30 
QuestionUsing A Regular Expression To Show Rows In Pandas (Python) Pin
Eddie Winch2-Feb-20 9:05
Eddie Winch2-Feb-20 9:05 
QuestionTSV out of a tab-based tree-like file Pin
DynV9-Nov-19 19:43
DynV9-Nov-19 19:43 
From a tab-based tree-like file, I'd like to get a flat-file DB (I think I'll make a program out of it and probably using ECMAScript/JavaScript, but whatever I end up doing I need a DB to start with). The file have different 1st-level block items, that is starting right after \n and ending just before either "\n\w" or EOF (end of file); I'm only interested in a certain kind: starting with "\nsystem\s", which I'll refer to as "system". A good portion of systems have a 2nd-level (non-block) item, that is starting right after \n\t and ending just before either "\n" or EOF (end of file); I'm only interested in those starting with "\n\tlink\s", which I'll refer to as "link"; any of those cases have > 1 link. I'm thinking the links can be in a CSV. All systems have a single 2nd-level "pos", which has 2 digits, that can be negative.

To summarize: Not all 1st-level items are systems but I'm only interested those. Some systems have no link, a decent portion have just 1, and a large portion have > 1, whichever of those cases I need links to be listed. A good portion of names, be it system or link are double-quoted which I don't want (the quotes).

The input file is https://github.com/endless-sky/endless-sky/blob/master/data/map.txt and the following is its current version 1st 2 systems trailed by an example of a system without a link and after is the output I'm looking to have from that.

I'd prefer to run the regex in Notepad++, but worse case I have Cygwin so I could use some *nix tools although please note often Cygwin version is old (so if someone want me to use the latest *nix tool, there's a decent chance I won't be able to in Cygwin).

Thank you kindly for your help

Sample input
```text
# Copyright (c) 2014 by Cookie Monster

system "1 Axis"
pos -1274.63 267.214
government Coalition
habitable 745.92
belt 1112
link "Sol Kimek"
link "4 Winter Rising"
link "4 Spring Rising"
link "3 Axis"
asteroids "small rock" 8 3.3166
asteroids "medium rock" 11 3.4454
asteroids "large rock" 1 3.1556
asteroids "small metal" 1 3.381
asteroids "medium metal" 149 4.347
asteroids "large metal" 11 3.9606
minables lead 11 6.87213
minables silicon 35 6.68659
minables tungsten 2 5.45307
trade Clothing 251
trade Electronics 831
trade Equipment 469
trade Food 231
trade "Heavy Metals" 1241
trade Industrial 767
trade "Luxury Goods" 1135
trade Medical 777
trade Metal 520
trade Plastic 384
fleet "Small Arach" 700
fleet "Large Arach" 1500
fleet "Small Kimek" 300
fleet "Large Kimek" 400
fleet "Small Saryd" 900
fleet "Large Saryd" 1800
fleet Heliarch 450
object
sprite star/k5
distance 49.335
period 18.0618
offset 180
object
sprite star/m0
distance 65.665
period 18.0618
object
sprite planet/rock12-b
distance 298.105
period 75.382
object
sprite planet/cloud4-b
distance 728.595
period 288.034
object "Celestial Third"
sprite planet/ice4
distance 951.355
period 429.762
object
sprite planet/gas9-b
distance 1811.79
period 1129.48
object
sprite planet/lava0
distance 229
period 12.994
object
sprite planet/dust1
distance 394
period 29.3248
object
sprite planet/dust5
distance 565
period 50.3574
object
sprite planet/ice8
distance 684
period 67.0771

system "10 Pole"
pos -1356.63 19.2137
government Coalition
habitable 486.68
belt 1765
link "16 Autumn Rising"
asteroids "small rock" 30 10.7996
asteroids "medium rock" 42 8.4448
asteroids "large rock" 2 8.12
asteroids "medium metal" 9 11.368
asteroids "large metal" 2 4.7096
minables neodymium 9 17.5036
minables silicon 17 18.2422
trade Clothing 335
trade Electronics 832
trade Equipment 444
trade Food 122
trade "Heavy Metals" 1228
trade Industrial 806
trade "Luxury Goods" 1009
trade Medical 710
trade Metal 300
trade Plastic 342
fleet "Small Arach" 1800
fleet "Large Arach" 8000
fleet "Small Kimek" 600
fleet "Large Kimek" 1600
fleet "Small Saryd" 1200
fleet "Large Saryd" 5000
fleet Heliarch 700
object
sprite star/k0
period 10
object
sprite planet/ice2
distance 158.89
period 36.3148
object "Second Rose"
sprite planet/cloud4
distance 483.25
period 192.618
object
sprite planet/rock17
distance 152
period 17.6262
object
sprite planet/lava2-b
distance 1069.5
period 634.175
object
sprite planet/gas16
distance 1649.46
period 1214.65
object
sprite planet/gas8-b
distance 2382.55
period 2108.63
object
sprite planet/rhea
distance 230
period 18.5682
object
sprite planet/dust3
distance 335
period 32.6395
object
sprite planet/ice0
distance 490
period 57.7392
system "yummy stew"
pos -666.66 333.333
government potato
habitable 999.99
belt 4444
asteroids "small rock" 8 3.3166
asteroids "medium rock" 11 3.4454
asteroids "large rock" 1 3.1556
asteroids "small metal" 1 3.381
asteroids "medium metal" 149 4.347
asteroids "large metal" 11 3.9606
minables lead 11 6.87213
minables silicon 35 6.68659
minables tungsten 2 5.45307
```
Output from sample
```text
System X Y links
1 Axis -1274.63 267.214 Sol Kimek, 4 Winter Rising, 4 Spring Rising, 3 Axis
10 Pole -1356.63 19.2137 16 Autumn Rising
yummy stew -666.66 333.333
```

Je vous salue du Québec !

Questiongetting all the image files in a HTML Inspection Pin
Member 1463488025-Oct-19 4:03
Member 1463488025-Oct-19 4:03 
QuestionRe: getting all the image files in a HTML Inspection Pin
Richard MacCutchan25-Oct-19 4:15
mveRichard MacCutchan25-Oct-19 4:15 
AnswerRe: getting all the image files in a HTML Inspection Pin
Member 1463488025-Oct-19 9:38
Member 1463488025-Oct-19 9:38 
GeneralRe: getting all the image files in a HTML Inspection Pin
Richard MacCutchan25-Oct-19 21:57
mveRichard MacCutchan25-Oct-19 21:57 
QuestionRegular Expression To Extract Everything Including the String And Before The First Space Character Pin
Member 1457241529-Aug-19 14:46
Member 1457241529-Aug-19 14:46 
AnswerRe: Regular Expression To Extract Everything Including the String And Before The First Space Character Pin
Richard MacCutchan29-Aug-19 20:43
mveRichard MacCutchan29-Aug-19 20:43 
GeneralRe: Regular Expression To Extract Everything Including the String And Before The First Space Character Pin
Member 1457241530-Aug-19 3:23
Member 1457241530-Aug-19 3:23 
GeneralRe: Regular Expression To Extract Everything Including the String And Before The First Space Character Pin
Member 1457241530-Aug-19 3:48
Member 1457241530-Aug-19 3:48 
GeneralRe: Regular Expression To Extract Everything Including the String And Before The First Space Character Pin
Richard MacCutchan30-Aug-19 4:35
mveRichard MacCutchan30-Aug-19 4:35 
GeneralRe: Regular Expression To Extract Everything Including the String And Before The First Space Character Pin
Member 1457241530-Aug-19 5:42
Member 1457241530-Aug-19 5:42 
GeneralRe: Regular Expression To Extract Everything Including the String And Before The First Space Character Pin
Member 1457241530-Aug-19 5:47
Member 1457241530-Aug-19 5:47 
GeneralRe: Regular Expression To Extract Everything Including the String And Before The First Space Character Pin
Member 1457241530-Aug-19 7:06
Member 1457241530-Aug-19 7:06 
GeneralRe: Regular Expression To Extract Everything Including the String And Before The First Space Character Pin
Richard MacCutchan30-Aug-19 21:42
mveRichard MacCutchan30-Aug-19 21:42 
QuestionRegex Expression to extract everything following a string and before a space Pin
Member 1457241529-Aug-19 6:30
Member 1457241529-Aug-19 6:30 
AnswerRe: Regex Expression to extract everything following a string and before a space Pin
Richard MacCutchan29-Aug-19 6:55
mveRichard MacCutchan29-Aug-19 6:55 
GeneralRe: Regex Expression to extract everything following a string and before a space Pin
Richard Deeming29-Aug-19 7:04
mveRichard Deeming29-Aug-19 7:04 
GeneralRe: Regex Expression to extract everything following a string and before a space Pin
Richard MacCutchan29-Aug-19 8:44
mveRichard MacCutchan29-Aug-19 8:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.