Webpack regex test that matches *.ts but not *.d.ts











up vote
1
down vote

favorite












I am using Webpack (2.3.3) to build my Aurelia app in TS. However, since I am using includeAll option for AureliaPlugin (2.0.0-rc.2), ts-loader (2.0.3) cries about d.ts files that has nothing exported emitting no output.



here is my rule for ts files: { test: /.ts$/, include: /ClientApp/, use: "ts-loader" }



I need to change the test value in a way that it matches files named *.ts except *.d.ts. Can you help me please?



Note: I see there is already a similar regex question but that one did not work for me.










share|improve this question


















  • 1




    Try /(^.?|.[^d]|[^.]d|[^.][^d]).ts$/. Also, see this SO thread.
    – Wiktor Stribiżew
    Apr 19 '17 at 8:38

















up vote
1
down vote

favorite












I am using Webpack (2.3.3) to build my Aurelia app in TS. However, since I am using includeAll option for AureliaPlugin (2.0.0-rc.2), ts-loader (2.0.3) cries about d.ts files that has nothing exported emitting no output.



here is my rule for ts files: { test: /.ts$/, include: /ClientApp/, use: "ts-loader" }



I need to change the test value in a way that it matches files named *.ts except *.d.ts. Can you help me please?



Note: I see there is already a similar regex question but that one did not work for me.










share|improve this question


















  • 1




    Try /(^.?|.[^d]|[^.]d|[^.][^d]).ts$/. Also, see this SO thread.
    – Wiktor Stribiżew
    Apr 19 '17 at 8:38















up vote
1
down vote

favorite









up vote
1
down vote

favorite











I am using Webpack (2.3.3) to build my Aurelia app in TS. However, since I am using includeAll option for AureliaPlugin (2.0.0-rc.2), ts-loader (2.0.3) cries about d.ts files that has nothing exported emitting no output.



here is my rule for ts files: { test: /.ts$/, include: /ClientApp/, use: "ts-loader" }



I need to change the test value in a way that it matches files named *.ts except *.d.ts. Can you help me please?



Note: I see there is already a similar regex question but that one did not work for me.










share|improve this question













I am using Webpack (2.3.3) to build my Aurelia app in TS. However, since I am using includeAll option for AureliaPlugin (2.0.0-rc.2), ts-loader (2.0.3) cries about d.ts files that has nothing exported emitting no output.



here is my rule for ts files: { test: /.ts$/, include: /ClientApp/, use: "ts-loader" }



I need to change the test value in a way that it matches files named *.ts except *.d.ts. Can you help me please?



Note: I see there is already a similar regex question but that one did not work for me.







regex webpack aurelia ts-loader






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Apr 19 '17 at 8:34









Hasan

1,11421834




1,11421834








  • 1




    Try /(^.?|.[^d]|[^.]d|[^.][^d]).ts$/. Also, see this SO thread.
    – Wiktor Stribiżew
    Apr 19 '17 at 8:38
















  • 1




    Try /(^.?|.[^d]|[^.]d|[^.][^d]).ts$/. Also, see this SO thread.
    – Wiktor Stribiżew
    Apr 19 '17 at 8:38










1




1




Try /(^.?|.[^d]|[^.]d|[^.][^d]).ts$/. Also, see this SO thread.
– Wiktor Stribiżew
Apr 19 '17 at 8:38






Try /(^.?|.[^d]|[^.]d|[^.][^d]).ts$/. Also, see this SO thread.
– Wiktor Stribiżew
Apr 19 '17 at 8:38














1 Answer
1






active

oldest

votes

















up vote
5
down vote



accepted










A regex that matches strings with .ts at the end but not .d.ts is



/(^.?|.[^d]|[^.]d|[^.][^d]).ts$/


See a regex demo. It is a POSIX style expression that will work with any regex engine.



Details





  • (^.?|.[^d]|[^.]d|[^.][^d]) - either of:



    • ^.? - start of string + any optional char


    • .[^d] - a dot and any char but d


    • [^.]d - any char but . and d


    • [^.][^d] - any char but . and then any char but d (this way, we match all but .d)




  • . - a literal dot


  • ts$ - ts at the end of string.


Alternatively, use a lookahead based solution:



/^(?!.*.d.ts$).*.ts$/


See another demo



Details:





  • ^ - start of string


  • (?!.*.d.ts$) - the string cannot end with .d.ts


  • .* - any 0+ chars up to the


  • .ts$ - .ts at the end of the string.


However, you might explore another option described in this SO thread.






share|improve this answer



















  • 1




    Never seen the function test in the wild so I had no idea about it. Ah, and the regex works, too. Thanks a lot!
    – Hasan
    Apr 19 '17 at 10:35






  • 1




    That's awesome!
    – Nonoroazoro
    Jul 3 at 3:34











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f43490499%2fwebpack-regex-test-that-matches-ts-but-not-d-ts%23new-answer', 'question_page');
}
);

Post as a guest
































1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
5
down vote



accepted










A regex that matches strings with .ts at the end but not .d.ts is



/(^.?|.[^d]|[^.]d|[^.][^d]).ts$/


See a regex demo. It is a POSIX style expression that will work with any regex engine.



Details





  • (^.?|.[^d]|[^.]d|[^.][^d]) - either of:



    • ^.? - start of string + any optional char


    • .[^d] - a dot and any char but d


    • [^.]d - any char but . and d


    • [^.][^d] - any char but . and then any char but d (this way, we match all but .d)




  • . - a literal dot


  • ts$ - ts at the end of string.


Alternatively, use a lookahead based solution:



/^(?!.*.d.ts$).*.ts$/


See another demo



Details:





  • ^ - start of string


  • (?!.*.d.ts$) - the string cannot end with .d.ts


  • .* - any 0+ chars up to the


  • .ts$ - .ts at the end of the string.


However, you might explore another option described in this SO thread.






share|improve this answer



















  • 1




    Never seen the function test in the wild so I had no idea about it. Ah, and the regex works, too. Thanks a lot!
    – Hasan
    Apr 19 '17 at 10:35






  • 1




    That's awesome!
    – Nonoroazoro
    Jul 3 at 3:34















up vote
5
down vote



accepted










A regex that matches strings with .ts at the end but not .d.ts is



/(^.?|.[^d]|[^.]d|[^.][^d]).ts$/


See a regex demo. It is a POSIX style expression that will work with any regex engine.



Details





  • (^.?|.[^d]|[^.]d|[^.][^d]) - either of:



    • ^.? - start of string + any optional char


    • .[^d] - a dot and any char but d


    • [^.]d - any char but . and d


    • [^.][^d] - any char but . and then any char but d (this way, we match all but .d)




  • . - a literal dot


  • ts$ - ts at the end of string.


Alternatively, use a lookahead based solution:



/^(?!.*.d.ts$).*.ts$/


See another demo



Details:





  • ^ - start of string


  • (?!.*.d.ts$) - the string cannot end with .d.ts


  • .* - any 0+ chars up to the


  • .ts$ - .ts at the end of the string.


However, you might explore another option described in this SO thread.






share|improve this answer



















  • 1




    Never seen the function test in the wild so I had no idea about it. Ah, and the regex works, too. Thanks a lot!
    – Hasan
    Apr 19 '17 at 10:35






  • 1




    That's awesome!
    – Nonoroazoro
    Jul 3 at 3:34













up vote
5
down vote



accepted







up vote
5
down vote



accepted






A regex that matches strings with .ts at the end but not .d.ts is



/(^.?|.[^d]|[^.]d|[^.][^d]).ts$/


See a regex demo. It is a POSIX style expression that will work with any regex engine.



Details





  • (^.?|.[^d]|[^.]d|[^.][^d]) - either of:



    • ^.? - start of string + any optional char


    • .[^d] - a dot and any char but d


    • [^.]d - any char but . and d


    • [^.][^d] - any char but . and then any char but d (this way, we match all but .d)




  • . - a literal dot


  • ts$ - ts at the end of string.


Alternatively, use a lookahead based solution:



/^(?!.*.d.ts$).*.ts$/


See another demo



Details:





  • ^ - start of string


  • (?!.*.d.ts$) - the string cannot end with .d.ts


  • .* - any 0+ chars up to the


  • .ts$ - .ts at the end of the string.


However, you might explore another option described in this SO thread.






share|improve this answer














A regex that matches strings with .ts at the end but not .d.ts is



/(^.?|.[^d]|[^.]d|[^.][^d]).ts$/


See a regex demo. It is a POSIX style expression that will work with any regex engine.



Details





  • (^.?|.[^d]|[^.]d|[^.][^d]) - either of:



    • ^.? - start of string + any optional char


    • .[^d] - a dot and any char but d


    • [^.]d - any char but . and d


    • [^.][^d] - any char but . and then any char but d (this way, we match all but .d)




  • . - a literal dot


  • ts$ - ts at the end of string.


Alternatively, use a lookahead based solution:



/^(?!.*.d.ts$).*.ts$/


See another demo



Details:





  • ^ - start of string


  • (?!.*.d.ts$) - the string cannot end with .d.ts


  • .* - any 0+ chars up to the


  • .ts$ - .ts at the end of the string.


However, you might explore another option described in this SO thread.







share|improve this answer














share|improve this answer



share|improve this answer








edited May 23 '17 at 11:46









Community

11




11










answered Apr 19 '17 at 10:33









Wiktor Stribiżew

299k16119194




299k16119194








  • 1




    Never seen the function test in the wild so I had no idea about it. Ah, and the regex works, too. Thanks a lot!
    – Hasan
    Apr 19 '17 at 10:35






  • 1




    That's awesome!
    – Nonoroazoro
    Jul 3 at 3:34














  • 1




    Never seen the function test in the wild so I had no idea about it. Ah, and the regex works, too. Thanks a lot!
    – Hasan
    Apr 19 '17 at 10:35






  • 1




    That's awesome!
    – Nonoroazoro
    Jul 3 at 3:34








1




1




Never seen the function test in the wild so I had no idea about it. Ah, and the regex works, too. Thanks a lot!
– Hasan
Apr 19 '17 at 10:35




Never seen the function test in the wild so I had no idea about it. Ah, and the regex works, too. Thanks a lot!
– Hasan
Apr 19 '17 at 10:35




1




1




That's awesome!
– Nonoroazoro
Jul 3 at 3:34




That's awesome!
– Nonoroazoro
Jul 3 at 3:34


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f43490499%2fwebpack-regex-test-that-matches-ts-but-not-d-ts%23new-answer', 'question_page');
}
);

Post as a guest




















































































Popular posts from this blog

Schultheiß

Verwaltungsgliederung Dänemarks

Liste der Kulturdenkmale in Wilsdruff